Professional Documents
Culture Documents
Lab 4
Lab 4
Lab 4
1. Draw the UML Class Diagram for the following class:
1
2. Implement the following UML Class Diagram with the given description:
3. State and describe each relationship in the following UML Class Diagram:
2
4. When a subclass inherits a superclass, does it inherit its constructors also? How do you tell
that when a subclass’s object is created the superclass’s constructor is invoked or not?
Write the code to prove it.
5. Create a Class called GeometricShape that has shapeName and two functions
calculatePerimeter and calculateArea. Create 3 more Classes; Square that has sideLength,
Rectangle that has length and width, and Circle that has radius. Each of these 3 Classes has
calculatePerimeter and CalculateArea. Design these 4 Classes and implement them, then
create an array of type GeometricShape in the main and initialize it with objects of
different types and then call the two methods calculatePerimeter and calculateArea for
each object.