100 Core Java Interview Questions and Answers - Part 1

Here are top selected core java interview questions asked in high level interviews, these questions may be helpful for both freshers or experienced professional going for interview.

1) What do you mean by platform independency. Is java a platform independent language ?

In general platform independency means, we can write and compile the source code on one machine having (windows, linux ..) and compiled code can be run on any other machine having same or different platform (windows, linux etc). In java source code is being compiled into byte code first, this bytecode can run on any other machine or platform having JVM(java virtual machine installed). So Java is considered to be a platform independent language.

2) What is JVM. Is JVM platform independent ?

Java or Java Virtual Machine is a Java runtime environment that makes the java compiled code run on a machine. JVM is not platform independent, different platform vendors provides platform specific JVM i.e. windows and linux have their own copy of JVM.

3) What is the difference between JVM and JDK ?

JDK is java development kit, it consists of Java Compiler, Java Libraries and JVM as well in it. JDK helps in development for Java programs, compile them and run them because of having JVM inside. JVM is purely Java virtual machine which is platform dependent runtime environment that makes java compile code run, we cannot compile java code using JVM.

4) What is the root class for all classes in Java ?

?Object ? class which resides in java.lang package is the base class for all classes in java, it means every class written in java extends Object class by default.

5) Is java a purely object oriented language, why ?

Java is not considered as a purely object oriented language because of having primitive datatypes like (int, char, boolean etc ). Although java contains equivalent wrapper classes(Integer, Char, Boolean etc) for those primitive types yet can not be considered a purely object oriented language.

6) Are Arrays primitive data types in java ?

No, In java everything is denoted by a class or Object, except those primitive data types. In java arrays are Objects and not primitive types.

7) What is OOPS ? Is java a object oriented language ?

An programming language is considered to be OOPS(Object oriented programming System) oriented. If it contains following four properties: 1) Abstraction 2) Polymorphism 3) Inheritance 4) Encapsulation Java contains all 4 mentioned attributes in it, hence Java is a object oriented language.

8) What is Abstraction in Java ?

Abstraction means to hide internal details and show only the essential details of an implementation. In java abstraction is gained using Abstract Classes and Interfaces.