1.
Create an abstract class Shape with abstract methods area()
and perimeter(). Create two subclasses Circle and Rectangle and
override the methods.
2. Create an abstract class PlayableMedia with an abstract
method play(). Extend it in two classes: Song and Video, and
implement the play() method.
3. Design an abstract class Vehicle with properties like speed, and
abstract method start(). Extend it in ElectricCar and PetrolCar.
4. Create a class Library with a final method rules() and a normal
method borrowBook(). Extend it in CityLibrary and try overriding
rules() (observe the error).
5. Create a constant configuration class with public static final
fields for MAX_USERS, SYSTEM_NAME, and VERSION.
6. Use final parameters in a method like greet(final String name)
and try modifying it inside the method to generate a compile-time
error.
7. Create a final class Constants with a utility method. Try
extending it in another class to demonstrate that it cannot be
inherited.
8. Create a class Animal with a constructor that prints "Animal
Created". Extend it in Dog and use super() to call the parent
constructor.
9. Use super.variableName to access a parent class variable that is
shadowed by a child class variable.
10. Create a parent class Account with a method show(), and
override it in child class SavingsAccount. In the child, call
super.show() inside your method.
11. Call a super method inside an overridden toString() to
include parent data in child class output.
12. Create an abstract class Device with a final method
powerOn() and an abstract method run(). Extend it in Printer and
use super to access parent logic.
13. Demonstrate final and super in multi-level inheritance,
e.g., Person → Employee → Manager, where Manager tries to
override a final method from Employee.