Dms - 6569a3dc02dbcjava Assignment5
Dms - 6569a3dc02dbcjava Assignment5
1. Create a class with a method that prints "This is parent class" and its subclass with another
method that prints "This is child class". Now, create an object for each of the class and call
1 - method of parent class by object of parent class
2 - method of child class by object of child class
3 - method of parent class by object of child class
2. Create a class Point2D with the data member and methods shown in the class diagram. Note
that the items with a minus sign (-) indicate private members and items with a plus sign (+)
indicate public members. Create a subclass called Point3D which is derived from the
superclass Point2D.Test the methods of both the classes by creating objects in the main
method of another class.
3. Create a derived class Circle inherited from the class Point2D (created in the previous
question) with the data member and methods shown in the following class diagram. Create a
subclass called Cylinder which is derived from the superclass Circle. Test the methods of
Circle and Cylinder classes by creating objects in the main method of another class
4. Create a class named 'Member' having the following members:
Data members
1 - Name
2 - Age
3 - Phone number
4 - Address
5 - Salary
It also has a method named 'printSalary' which prints the salary of the members.
Two classes 'Employee' and 'Manager' inherits the 'Member' class. The 'Employee' and
'Manager' classes have data members 'specialization' and 'department' respectively. Now,
assign name, age, phone number, address and salary to an employee and a manager by
making an object of both of these classes and print the same.
5. Write a superclass called Shape (as shown in the class diagram), which contains:
a. Two instance variables color (String) and filled (boolean).
b. Two constructors: a no-argument constructor that initializes the color to "green" and
filled to true, and a constructor that initializes the color and filled to the given values.
c. Getter and setter for all the instance variables. By convention, the getter for a
boolean variable xxx is called isXXX() (instead of getXxx() for all the other types).
d. A toString() method that returns "A Shape with color of xxx and filled/Not filled". Write
a test program to test all the methods defined in Shape.
Write two subclasses of Shape called Circle and Rectangle, as shown in the class diagram.
The Circle class contains: