Java InterView Questions OOPS CONCEPT



41) Can we override static method?

No, you can't override the static method because they are the part of class not object.

42) Why we cannot override static method?

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.

43) Can we override the overloaded method?

Yes.

44) Difference between method Overloading and Overriding.

Method Overloading
Method Overriding
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) method overlaoding 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.

45) Can you have virtual functions in Java?

Yes, all functions in Java are virtual by default.

46) What is covariant return type?

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


47) What is final variable?

If you make any variable as final, you cannot change the value of final variable(It will be constant).

48) What is final method?

Final methods can't be overridden.

49) What is final class?

Final class can't be inherited.

50) What is blank final variable?

A final variable, not initalized at the time of declaration, is known as blank final variable.more
  • 1          2      3          4         5          6        7        8 
  • Page 5 OOPS concepts Java Interview questions


No comments:

Post a Comment