In the above examples, java compiler doesn’t know the actual implementation class of Shape that will be used at runtime, hence runtime polymorphism. 4. Inheritance Inheritanceis the object-oriented programming concept where an object is based on another object. Inheritance is the mechanism of co...
Q: How is abstraction achieved in Java? A: Through the use of abstract classes and interfaces, which define methods without necessarily providing their implementations. Q: When would you use an abstract class versus an interface? A: Use an abstract class when you want to share code and state...