Skip to main content

Posts

Showing posts from February, 2017

Practice Set: Inheritance, String, Array and ArrayList

1. WAP to create a class Person with attributes Name, Age and Mobile Number and a method to display the details of a person and an abstract method to assign the designation of the person as per the user input at run time. Create two subclasses of Person as Student and Employee and write the methods to accept the Organization name from the User at runtime and methods to display all the details of Student/Employee. Create the objects of both the subclasses using constructors to initialize the instance variables of the class and then display all the details of both.  2. WAP to create a class Vehicle having data members Mileage and fuel and methods to add the fuel. Create two sub classes of Vehicle i.e. Bike and Car each having data members Name, and Max_Speed and method to calculate the remaining fuel. From a class Race create the objects of both the subclasses using appropriate constructors to initialize the data members after taking the input from the user. Display the remaining fuel