Java Assignment 2
Java Assignment 2
Short Questions
Long Questions
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.