Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Java

Uploaded by

ynotmrhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Java

Uploaded by

ynotmrhari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

IT1301A – OBJECT ORIENTED PROGRAMMING

ASSIGNMENT 1

1. Explain in detail OOP concepts, Feature of Java. (UNIT 1)


2. Discuss different types of constructor with suitable example program. (UNIT 1)
3. Write a simple Vehicle class that has fields for (at least) current speed, current direction in
degrees, and owner name. Add a static field to your Vehicle class to hold the next vehicle
identification number, and a non-static field to the Vehicle class to hold each car's ID
number. Add two constructors to Vehicle: a no-arg constructor and one that takes an initial
owner's name. Add a changeSpeed method that changes the current speed of the vehicle to
a passed-in value and add a stop method that sets the speed to zero.Create an extended class
called PassengerVehicle to add a capability for counting the number of seats available in
the car and the number currently occupied. Provide a main method in PassengerVehicle to
create a few of these objects and print them out. (UNIT II)

4. Write a simple Vehicle class that has fields for (at least) current speed, current direction in
degrees, and owner name. Add a static field to your Vehicle class to hold the next vehicle
identification number, and a non-static field to the Vehicle class to hold each car's ID
number. Add two constructors to Vehicle: a no-arg constructor and one that takes an initial
owner's name. Add a changeSpeed method that changes the current speed of the vehicle to
a passed-in value and add a stop method that sets the speed to zero. Change Vehicle so that
it has an EnergySource object reference, which is associated with the Vehicle in its
constructor. EnergySource must be an abstract class, because a GasTank object's measure
of fullness will differ from that of a Battery object. Put an abstract empty method in
EnergySource and implement it in GasTank and Battery classes. Add a start method to
Vehicle that ensures that the energy source isn't empty. (UNIT II)

Note. You are instructed to execute the above two programs step by step, and note all the error
occurred during compilation and execution along with error description , locations of error and
Write how do you resolve it.

You might also like