You are on page 1of 2

Java Assignment

Short Questions

1. What is difference between instance variable and class variable?


2. What is difference between concrete class and abstract class
3. What are types of constructors?
4. State the use of „this‟ keyword.
5. State the use of toString method
6. What is difference between using ++ and equals method?
7. What is use of String and StringBuffer class?
8. How is static method invoked?
9. What is the purpose of inheritance?
10. State the use of protected keyword.
11. What is use of super keyword?
12. What is marker interface?
13. What is functional interface?
14. How can we prevent a class from being inherited in java?
15. What is us of final keyword
16. Write the syntax of inheriting one class from another.
17. A subclass should define a constructor if the superclass has one-comment
18. How does a subclass invoke the superclass constructor?
19. What is the purpose of an abstract class?
20. What is dynamic binding?

Long Questions

1. Explain the usage of this keyword.


2. What are wrapper classes? How can a wrapper class object be created and accessed?
3. Write note on package. What are advantages of packages?
4. Explain the toString() and hashCode() method.

Programming Questions

1. Write a Java program to create a super class Vehicle having members Company and
price.
Derive 2 different classes LightMotorVehicle (members – mileage) and
HeavyMotorVehicle
(members – capacity-in-tons). Accept the information for n vehicles and display the
information in appropriate form. While taking data, ask the user about the type of
vehicle first.
2. 1. Define an abstract class “Staff” with members name and address. Define two sub-
classes of this class – “FullTimeStaff” (department, salary) and “PartTimeStaff”
(number-of-hours, rate-per-hour). Define appropriate constructors. Create n objects
which could be of either FullTimeStaff or PartTimeStaff class by asking the user‟s
choice. Display details of all “FullTimeStaff” objects and all “PartTimeStaff” objects.
3. Write a Java program to create a Package “SY” which has a class SYMarks (members

ComputerTotal, MathsTotal, and ElectronicsTotal). Create another package TY which
has a class TYMarks (members – Theory, Practicals). Create n objects of Student
class (having rollNumber,name, SYMarks and TYMarks). Add the marks of SY and
TY computer subjects and calculate the Grade („A‟ for >= 70, „B‟ for >= 60 „C‟ for
>= 50 , Pass Class for > =40 else „FAIL‟) and display the result of the student in
proper format.

You might also like