Core Java Interview Questions

Table of Contents

Java is the high-level, object-oriented, robust, secure programming, platform-independent, high performance, Multithreaded, and portable programming language.

A Quick Overview of Core Java

ABOUT CORE JAVA
What is Core Java?
Core Java is the most fundamental and the purest form of Java which set the establishment for different releases of the programming language.
Latest versionJava 12
Developed byOracle Corporation
Official websitehttps://www.java.com

Development History

In June 1991, James Gosling, Mike Sheridan, and Patrick Naughton started the Java language venture. It was initially intended for little, installed frameworks in electronic apparatuses like set-top boxes. It took a year and a half to build up the first working version. Java is one of the world’s most significant and broadly utilized coding languages, and it has held this differentiation for a long time. Dissimilar to some other coding whose impact has worn with a section of time, while Java has developed.
Java was at first launched as Java 1.0 however not long after its initial release, Java 1.1 was launched. Java 1.1 reclassified event handling, new library components were included.

Latest Version

The most recent variant of Java will be Java 12 or JDK 12 which was released on nineteenth March 2019.

Uses of Java

Java is broadly utilized in each edge of the world and of human life. Java isn’t just utilized in programming but at the same time is generally utilized in structuring hardware controlling programming segments.

It is utilized in creating Desktop Applications, Web Applications like Linkedin.com, Snapdeal.com, and so on. And Mobile Operating System like Android, Embedded Systems, Robotics, games, and so forth.

In this article, I am going to show likely the most Core Java Interview Questions and Answers which will help you in the meeting system.

Q. 1) what are static blocks and static initalizers in Java ?
Static blocks or static initializers are used to initalize static fields in java. we declare static blocks when we want to intialize static fields in our class. Static blocks gets executed exactly once when the class is loaded. Static blocks are executed even before the constructors are executed.

Q. 2) How to call one constructor from the other constructor ?
With in the same class if we want to call one constructor from other we use this() method. Based on the number of parameters we pass appropriate this() method is called. Restrictions for using this method:

  • this must be the first statement in the constructor.
  •  we cannot use two this() methods in the constructor

Q. 3) What is method overriding in java ?
If we have methods with same signature (same name, same signature, same return type) in super class and subclass then we say subclass method is overridden by superclass.
When to use overriding in java?
If we want same method with different behaviour in superclass and subclass then we go for overriding. When we call overridden method with subclass reference subclass method is called hiding the superclass method.

Q. 4) What is super keyword in java ?
Variables and methods of super class can be overridden in subclass . In case of overriding , a subclass object call its own variables and methods. Subclass cannot access the variables and methods of superclass because the overridden variables or methods hides the methods and variables of super class. But still java provides a way to access super class members even if its members are overridden. Super is used to access superclass variables, methods, constructors.
Super can be used in two forms :

  1. First form is for calling super class constructor. 
  2. Second one is to call super class variables,methods. Super if present must be the first statement.

Q. 5) Why java is platform independent?
The most unique feature of java is platform independent. In any programming language soruce code is compiled in to executable code . This cannot be run across all platforms. When javac compiles a java program it generates an executable file called .class file. class file contains byte codes. Byte codes are interpreted only by JVM’s . Since these JVM’s are made available across all platforms by Sun Microsystems, we can execute this byte code in any platform. Byte code generated in windows environment can also be executed in linux environment. This makes java platform independent.

Q. 6) What is method overloading in java ?
A class having two or more methods with same name but with different arguments then we say that those methods are overloaded.
Static polymorphism is achieved in java using method overloading. Method overloading is used when we want the methods to perform similar tasks but with different inputs or values. When an overloaded method is invoked java first checks the method name, and the number of arguments ,type of arguments; based on this compiler executes this method.
Compiler decides which method to call at compile time. By using overloading static polymorphism or static binding can be achieved in java.
Note : Return type is not part of method signature. we may have methods with different return types but return type alone is not sufficient to call a method in java.

Q. 7) What is JIT compiler ?
JIT compiler stands for Just in time compiler. JIT compiler compiles byte code in to executable code . JIT a part of JVM .JIT cannot convert complete java program in to executable code it converts as and when it is needed during execution.

Q. 8) What is bytecode in java ?
When a javac compiler compiler compiles a class it generates .class file. This .class file contains set of instructions called byte code. Byte code is a machine independent language and contains set of instructions which are to be executed only by JVM. JVM can understand this byte codes.

Q. 9) Difference between this() and super() in java ?
this() is used to access one constructor from another with in the same class while super() is used to access superclass constructor. Either this() or super() exists it must be the first statement in the constructor.

Q. 10) What is a class ?  Classes are fundamental or basic unit in Object Oriented Programming .A class is kind of blueprint or template for objects. Class defines variables, methods. A class tells what type of objects we are creating. For example take Department class tells us we can create department type objects. We can create any number of department objects. All programming constructs in java reside in class. When JVM starts running it first looks for the class when we compile. Every Java application must have atleast one class and one main method. Class starts with class keyword. A class definition must be saved in class file that has same as class name. File name must end with .java extension.
public class FirstClass
{public static void main(String[] args)
{System.out.println(“My First class”);
}
}

CONCLUSION

Java offers genuine plausibility that most programs can be written in a sort of safe language. In any case, for Java to be comprehensively helpful, it needs to have more expressive power than it does at present.

Have Some Questions? Share with us

Leave a Comment

Your email address will not be published.

Scroll to Top