Object oriented concepts UE Past Papers Questions.


View All Courses

(138) Question Category: Short answers

What is an interface?

Answer / Solution

UNSOLVED

(139) Question Category: Multiple choices

  • Create a class named Circle with fields named redius , diameter and area. Include a constructor that sets the radius to 1 and calculates the other two values. Also include methods named setRadius() and getRadius(). The setRadius() method not only sets the radius, it also calculates the other two values. (The diameter of a circle is twice the radius and the area of a circle is pi multiplied by square of the radius). Save the class as Circle.java
  • In the same class main() method that declares several circle objects . Using the setRadius() method, assign one circle a small radius value and assign another a larger radius value. Do not assign a value to the radius of the third circle, instead retain the value assigned at construction. Ditsplay all the values for all the circle objects.

Answer / Solution

UNSOLVED

(140) Question Category: Multiple choices

  • Create a class named Vehicle that acts as a superclass for vehicle types. The Veehicle class contains private variables for the number of wheels and average number of kilometers per liter. The Vehicle class also contains a constructor with integer arguments  for the number of wheels and average kilometers per liter, and a toString() method that returns a String containing these values.
  • Create two subclasses, Car and MotorCycle that extend the Vehicle class. Each subclass contains a constructor that accepts the kilometer-per liter value as an argument and forces the number of wheels to appropriate value - 2 for a MotorCycle and 4 for a Car.
  • Create a UseVehicleDemo class which contains main() method in which you declare and instantiate the Vehicle , Car and MotorCycle objects and display the objects` values.

Answer / Solution

UNSOLVED

View All Courses
News & Updates | Recently
Recent Updates
questions

2024-05-02: questions

Questions Uploaded on 2024-05-02


questions

2024-03-29: questions

Questions Uploaded on 2024-03-29


questions

2024-03-19: questions

Questions Uploaded on 2024-03-19

Dismissible in 10 seconds