Our website is made possible by displaying online advertisements to our visitors.Please consider supporting us by disabling your ad blocker.
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Translate it in your own Language

Print this Job Post

Print Friendly and PDF

Monday, May 26, 2014

Core Java – OOPs Concepts: Method Overriding Interview Questions

Question-40: What is method overriding:
Answer:
If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding. It is used for runtime polymorphism and to provide the specific implementation of the method.


Question-41: Can we override static method?
Answer:
No, you can’t override the static method because they are the part of class not object.


Question-42: Why we cannot override static method?
Answer:
It is because the static method is the part of class and it is bound with class whereas instance method is bound with object and static gets memory in class area and instance gets memory in heap.


Question-43: Can we override the overloaded method?
 Answer:
Yes.


Question-44: Difference between method Overloading and Overriding.
Answer:


  1. Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class. 
  2. methodoverlaoding is occurs within the class. Method overriding occurs in two classes that have IS-A relationship. 
  3. In this case, parameter must be different. In this case, parameter must be same. 


Question-45:Can you have virtual functions in Java?
Answer:
Yes, all functions in Java are virtual by default.


Question-46: What is covariant return type?
Answer:
Now, since java5, it is possible to override any method by changing the return type if the return type of the subclass overriding method is subclass type. It is known as covariant return type.

Core Java – OOPs Concepts: final keyword Interview Questions

No comments:

Post a Comment

Copyright @ CrackMNC 2014-2024
Divas Nikhra Theme by Crack MNC