Core Java Interview Questions Part 11/Polymorphism.

Hello Friends, In this Blog Post I am going to let you know about a few more interview questions of core java related to Polymorphism.

Core java interview questions cover all the important questions of the topics mentioned above.

These core java interview questions are a great help to remember all the important highlights and important topics from each java chapter.

These interview questions will surely help to understand a few very confusing concepts in java.

What is coercion?

coercion is the automatic conversion between different data types done by a compiler.

What is conversion?

Conversion is the explicit change in the data type specified by the cast operator.

What is a method signature?

Method signature represents the method name along with method parameters.

What is method overloading?

Writing two or more methods in the same class in such a way that each method has the same name but with a different method, a signature is called method overloading.

What is method overriding?

Writing two or more methods in super and subclass such that the methods have the same name and the same signature is called method overriding.

What is the difference between method overloading and method overriding?

The difference between method overloading and method overriding is given below.

Writing two or more methods with the same name but with different signatures is called method overloading.

Writing two or more methods with the same name and same signature is called method overriding.

Method overloading is done in the same class.

Method overriding is done in super and subclass.

In method overloading, the method return type can be the same or different.

In method overriding, the method return type should also be the same.

JVM decides which method is called depending on the difference in the method signature.

JVM decides which method is called depending on the data type(class) of the object used to call the method.

Method overloading is done when the programmer wants to extend the already available feature.

Method overriding is done when the programmer wants to provide a different implementation(body) for the same feature.

Method overloading is code refinement. The same method is refined to perform a different task.

Method overriding is code replacement. The sub-class method overrides(replaces) the super-class method.

Can you override the private method?

No, private methods are not available in the subclasses, so they can not be overridden.

Can we take private methods and final methods as the same?

Yes, the java compiler assigns the value for the private methods at the time of compilation. Also, private methods can not be modified at run time. This is the same case with the final methods also.

Neither the private methods nor the final methods can be overridden. So, private methods can be taken as the final methods.

What is final?

‘final’ keyword is used in two ways:

It is used to declare the constants, as :

final double PI = 3.14159; //PI is constant.

It is used to prevent inheritance, as :

final class A // Subclass to A cannot be created.

What is the difference between dynamic polymorphism and static polymorphism?

Dynamic polymorphism is the polymorphism exhibited at runtime. Here, the java compiler does not understand which method is called at compilation time. Only JVM decides which method is called at runtime. Method overloading and method overriding using instance methods are examples of dynamic polymorphism.

Static polymorphism is the polymorphism exhibited at compile time. Here, the java compiler knows which method is called. Method overloading and method overriding using static methods; method overriding using the private or final method are examples of static polymorphism.

So this was all about the Core java interview questions on this topic.

These Core java interview questions could be a great help in your college viva, academic study, and any job interview.

You can also go through a few more amazing blog links related to core java interview questions:

Core Java Interview Questions Part 1
Core Java Interview Questions Part 2
Core Java Interview Questions Part 3
Core Java Interview Questions Part 4
Core Java Interview Questions Part 5
Core Java Interview Questions Part 6
Core Java Interview Questions Part 7
Core Java Interview Questions Part 8
Core Java Interview Questions Part 9
Core Java Interview Questions Part 10
Core Java Interview Questions Part 11
Core Java Interview Questions Part 12
Core Java Interview Questions Part 13
Core Java Interview Questions Part 14
Core Java Interview Questions Part 15
Core Java Interview Questions Part 16
Core Java Interview Questions Part 17
Core Java Interview Questions Part 18
Core Java Interview Questions Part 19
Core Java Interview Questions Part 20
Core Java Interview Questions Part 21
JVM In Hindi: Java Virtual Machine
C ++ और Java में अंतर हिंदी में…

In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.

Hope! you would have enjoyed this post about Core Java Interview Questions Part 11/Polymorphism.

Please feel free to give your important feedback in the comment section below.

Have a great time!

Anurag

I am a blogger by passion, a software engineer by profession, a singer by consideration and rest of things that I do is for my destination.