Learning Java: Interview Questions

When we are searching for jobs, it is really appropriated to start preparing ourselves for incoming interviews. We have to remember to be honest and express our thought while we are responding with precision.

Sometimes recruiters can be so polite when they interview you, and it is easy to think there’s no opportunity to pass it, but relax, don’t get intimidated by that, it is just a way to see if you get nervous.

Here we have some some Java interview Question that you may encounter in an interview:

Why is Java platform independent ?

Java have the principle of write once and run anywhere, but how ? A Java program it is compile into byte code which then run into any other JVM(Java Virtual Machine) and made it possible to run on different operating system.

Can you change the contents of a final array ?

Even if it is set as final, you can change what it is inside of an array in Java ,the contents in the array are allocate in a particular location in the memory which can’t be changed.

What is the difference between abstract class and interfaces?

Abstract class and interfaces are the great example of principle of inheritance. They both can be accessed by using key words: extends and implements. Unfortunately you can only extends one abstract class but can inherit as many interfaces as you can. Abstract class unlike interfaces can hold abstract and non-abstract methods where interfaces only can have abstract methods.

You can see more about about this in my previous abstract vs interfaces post

What is polymorphism?

Polymorphism could be translate as “many forms “. In Java polymorphism is the principle of adapting many form which means that allow you to use resources from other classes without needing to know which class is using it. An example of polymorphism are override and overload.

What is the difference between constructor and class method?

Constructors is a method that initialize objects of a class and doesn’t provide return statement. Also Constructors can’t be abstract nor final because the access it is need it. Unlike constructors, methods can have behaviors, have return statements or not and can be set as others access modifiers besides public.

Can main method be overloaded ?

You can see these and more questions like these here

Leave a comment

Design a site like this with WordPress.com
Get started