OOPJ - Practical Assignment-I PDF
OOPJ - Practical Assignment-I PDF
Subject: OOPJ
Assignment-I
1. Declare a class called employee having employee_id and employee_name as members.
Extend class employee to have a subclass called salary having designation and
monthly_salary as embers. Define following:
- Required constructors
- A method to find and display all details of employees drawing salary more than Rs. 20000/-
- Method main for creating an array for storing these details given as command line
arguments and showing usage of above methods.
3. The Transport interface declares a deliver() method. The abstract class Animal is the
superclass of the Tiger, Camel, Deer and Donkey classes. The Transport interface is
implemented by the Camel and Donkey classes. Write a test program that initialize an array
of four Animal objects. If the object implements the Transport interface, the deliver() method
is invoked.
4. The abstract Vegetable class has three subclasses named Potato, Brinjal and Tomato. Write
an application that demonstrates how to establish this class hierarchy. Declare one instance
variable of type String that indicates the color of a vegetable. Create and display instances of
these objects. Override the toString() method of Object to return a string with the name of the
vegetable and its color.
5. Describe abstract class called Shape which has three subclasses say Triangle, Rectangle,
Circle. Define one method area() in the abstract class and override this area() in these three
subclasses to calculate for specific object i.e. area() of Triangle subclass should calculate area
of triangle etc. Same for Rectangle and Circle.
6. Declare a class called book having author_name as private data member. Extend book class to
have two sub classes called book_publication & paper_publication. Each of these classes have
private member called title. Write a complete program to show usage of dynamic method
dispatch (dynamic polymorphism) to display book or paper publications of given author. Use
command line arguments for inputting data.
7. Write a program that illustrates interface inheritance. Interface A is extended by A1 and A2.
Interface A12 inherits from both P1 and P2.Each interface declares one constant and one
method. Class B implements A12.Instantiate B and invoke each of its methods. Each method
displays one of the constants.