KEMBAR78
Assignment Abstraction | PDF
0% found this document useful (0 votes)
8 views1 page

Assignment Abstraction

The document outlines a series of programming tasks involving the creation of abstract classes, subclasses, and method overriding in an object-oriented programming context. It includes examples such as defining shapes, media types, vehicles, and libraries, as well as demonstrating the use of final classes and parameters. Additionally, it covers inheritance concepts, including accessing parent class methods and variables, and the implications of final methods in multi-level inheritance scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Assignment Abstraction

The document outlines a series of programming tasks involving the creation of abstract classes, subclasses, and method overriding in an object-oriented programming context. It includes examples such as defining shapes, media types, vehicles, and libraries, as well as demonstrating the use of final classes and parameters. Additionally, it covers inheritance concepts, including accessing parent class methods and variables, and the implications of final methods in multi-level inheritance scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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.

You might also like