Java Assignment-02
Java Assignment-02
Q.1(a) In Java, constructors cannot be inherited but can be invoked using super(). Explain
why constructors are not inherited in Java and how super() is used to invoke a superclass
constructor in a subclass. Provide a scenario where explicitly calling super() in a subclass
constructor is necessary.
Q.2 (a) Java supports inner classes (regular, static, local, and anonymous). Explain the key
differences between a local inner class and an anonymous inner class. In what situations
would an anonymous inner class be preferred over a regular inner class? Provide a real-world
use case where an anonymous inner class is the best choice.
(CO2)- 5 Marks
Q.3 (a) Suppose you are designing a software system for a bank. Which OOP principles
would you implement to ensure security and modularity? Justify your answer with examples.
(CO2)- 5 Marks
Q.4. You are designing a Ride-Booking System where different types of rides (CarRide,
BikeRide, LuxuryRide) follow a common interface but charge different fares.
(CO2)- 5 Marks
Q.5 Design and implement a Java program that demonstrates both dynamic method dispatch
and Early Binding (Static method dispatch).
(CO2)- 5 Marks