Question-41. What is Runtime Polymorphism ?

Answer- Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time.

In this process, an overridden method is called through the reference variable of a super class. The determination of the method to be called is based on the object being referred to by the reference variable.

Question-42. Can you achieve Runtime Polymorphism by data members ?

Answer- No.

Question-43. What is the difference between static binding and dynamic binding? ?

Answer- In case of static binding type of object is determined at compile time whereas in dynamic binding type of object is determined at runtime.

Question-44. What is abstraction ?

Answer- Abstraction is a process of hiding the implementation details and showing only functionality to the user.

Abstraction lets you focus on what the object does instead of how it does it.

Question-45. What is the difference between abstraction and encapsulation ?

Answer- Abstraction hides the implementation details whereas encapsulation wraps code and data into a single unit.

Question-46. What is abstract class ?

Answer- A class that is declared as abstract is known as abstract class. It needs to be extended and its method implemented. It cannot be instantiated.

Question-46. Can there be any abstract method without abstract class? ?

Answer- No, if there is any abstract method in a class, that class must be abstract.

Question-47. Can you use abstract and final both with a method ?

Answer- No, because abstract method needs to be overridden whereas you can’t override final method.

Question-48. Is it possible to instantiate the abstract class ?

Answer-No, abstract class can never be instantiated.

Question-49. What is interface ?

Answer-Interface is a blueprint of a class that have static constants and abstract methods. It can be used to achieve fully abstraction and multiple inheritance.

Question-50. Can you declare an interface method static ?

Answer- No, because methods of an interface is abstract by default, and static and abstract keywords can’t be used together.