Hello Friends, I am writing this post to provide you all core java interview questions from beginners to expert level. We have a lot of websites available to study interview questions, but there is no single website who provide all questions in one place. I will try to put each and every important core JAVA questions in this blog, so one can get all core java interview questions in a single place.
Core JAVA interview questions :
1.) What is OOPs? What are basic OOPs concepts?
OOP (Object Orient Programming) - OOPs is a programming system in which the basic unit of programming is an Object. Any OOPs program is basically a collection of objects.
Basic concepts of OOPs are -
2.) What is Abstraction? How abstraction is achieved in Java?
Abstraction Definition - Abstraction is process of hiding the implementation details of any system, and showing only the functionalities user wants to use.
For understanding the concept we can take example of our mobile phone. In mobile all internal implementations (like - chips, circuits, wiring and connectivity etc) are hided from us and we only see the functionalities we can perform. We do not care about internal implementations.
In java programming we can achieve abstraction by using interfaces or abstract classes.
3.) What is inheritance. Does JAVA supports multiple inheritance?
Inheritance Definition - Inheritance is process where one class inherits the members and methods of some other class. This inherited class is known as parent(super) class and class which inherits the properties is called child (sub) class.
In java inheritance can be performed by either extending class or implementing interface.
extends or implements keywords are used for inheritance in java.
A class can extends a class.
A class can implements an interface.
An interface can extends an interface.
Multiple inheritance of classes in not allowed in java, as it creates diamond problem. (I will explain diamond problem in next part)
We can implements multiple interface in java, because in interfaces there are only declarations (no implementation) so it do not creates any issue.
4.) What is Polymorphism? How Polymorphism achieved in java?
OR
Describe Polymorphism. What are the types of Polymorphism?
Polymorphism Definition - Polymorphism is ability of an object in which one object can be presented in many forms.
Two types of polymorphism performed in Java - Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding).
Method overloading is an example of Compile time polymorphism, while method overriding is an example of Runtime polymorphism.
5.) What is Encapsulation? How encapsulation achieved in Java?
Encapsulation Definition - Encapsulation is concept of binding the data and functions together in a single entity. So that both data and functions will be secure from outside misuse.
In Java encapsulation is achieved by using the classes. All data (members) and functions (methods) are bind together in a class. Different modifiers can be used with class , data and methods to make them secure.
6.) What is JAVA technology?
Java is a programming language and computing platform first released by Sun Microsystems in 1995.
7.) Is Java a fully Object Oriented programming language?
No, Java is not a fully Object Oriented Programming language because Java also use primitive data types with objects.
8.) Why JAVA is called a platform independent language?
A JAVA program written on one platform can be run on any platform, that's why JAVA is called platform independent.
Java achieve the independence with the help of JVM.
9.) What is JVM? Is JVM platform independent?
JVM (Java Virtual Machine) is an abstract machine which provides run-time environment to run a java program. JVM is responsible to convert the byte codes of .class files generated by compiler into the machine readable format.
JVM is a specification that formally describes what is required of a JVM implementation. There are many JVM implementations available from Oracle, IBM and BEA systems.
JVM is platform dependent. We need to install a specific JVM according to the machine OS.
10.) What is the difference between JDK, JRE and JVM?
JDK (Java Development Kit) - JDK provides tools, libraries and executables to compile, execute and debug the Java program. JRE is a part of JDK.
JVM(Java Virtual Machine) - JVM (Java Virtual Machine) is an abstract machine which provides run-time environment to run a java program. JVM is responsible to convert the byte codes of .class files generated by compiler into the machine readable format. That provides the platform independent feature to java.
JRE(Java Runtime Environment) - JRE is JVM's implementation that is responsible to run any java program. If you want to run any java program, you only needs to install JRE.
Core JAVA interview questions :
1.) What is OOPs? What are basic OOPs concepts?
OOP (Object Orient Programming) - OOPs is a programming system in which the basic unit of programming is an Object. Any OOPs program is basically a collection of objects.
Basic concepts of OOPs are -
- Abstraction
- Inheritance
- Polymorphism
- Encapsulation
2.) What is Abstraction? How abstraction is achieved in Java?
Abstraction Definition - Abstraction is process of hiding the implementation details of any system, and showing only the functionalities user wants to use.
For understanding the concept we can take example of our mobile phone. In mobile all internal implementations (like - chips, circuits, wiring and connectivity etc) are hided from us and we only see the functionalities we can perform. We do not care about internal implementations.
In java programming we can achieve abstraction by using interfaces or abstract classes.
3.) What is inheritance. Does JAVA supports multiple inheritance?
Inheritance Definition - Inheritance is process where one class inherits the members and methods of some other class. This inherited class is known as parent(super) class and class which inherits the properties is called child (sub) class.
In java inheritance can be performed by either extending class or implementing interface.
extends or implements keywords are used for inheritance in java.
A class can extends a class.
A class can implements an interface.
An interface can extends an interface.
Multiple inheritance of classes in not allowed in java, as it creates diamond problem. (I will explain diamond problem in next part)
We can implements multiple interface in java, because in interfaces there are only declarations (no implementation) so it do not creates any issue.
4.) What is Polymorphism? How Polymorphism achieved in java?
OR
Describe Polymorphism. What are the types of Polymorphism?
Polymorphism Definition - Polymorphism is ability of an object in which one object can be presented in many forms.
Two types of polymorphism performed in Java - Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding).
Method overloading is an example of Compile time polymorphism, while method overriding is an example of Runtime polymorphism.
5.) What is Encapsulation? How encapsulation achieved in Java?
Encapsulation Definition - Encapsulation is concept of binding the data and functions together in a single entity. So that both data and functions will be secure from outside misuse.
In Java encapsulation is achieved by using the classes. All data (members) and functions (methods) are bind together in a class. Different modifiers can be used with class , data and methods to make them secure.
6.) What is JAVA technology?
Java is a programming language and computing platform first released by Sun Microsystems in 1995.
7.) Is Java a fully Object Oriented programming language?
No, Java is not a fully Object Oriented Programming language because Java also use primitive data types with objects.
8.) Why JAVA is called a platform independent language?
A JAVA program written on one platform can be run on any platform, that's why JAVA is called platform independent.
Java achieve the independence with the help of JVM.
9.) What is JVM? Is JVM platform independent?
JVM (Java Virtual Machine) is an abstract machine which provides run-time environment to run a java program. JVM is responsible to convert the byte codes of .class files generated by compiler into the machine readable format.
JVM is a specification that formally describes what is required of a JVM implementation. There are many JVM implementations available from Oracle, IBM and BEA systems.
JVM is platform dependent. We need to install a specific JVM according to the machine OS.
10.) What is the difference between JDK, JRE and JVM?
JDK (Java Development Kit) - JDK provides tools, libraries and executables to compile, execute and debug the Java program. JRE is a part of JDK.
JVM(Java Virtual Machine) - JVM (Java Virtual Machine) is an abstract machine which provides run-time environment to run a java program. JVM is responsible to convert the byte codes of .class files generated by compiler into the machine readable format. That provides the platform independent feature to java.
JRE(Java Runtime Environment) - JRE is JVM's implementation that is responsible to run any java program. If you want to run any java program, you only needs to install JRE.
_____________________________________________
***********************Keep Studying ***********************
Good amount of information, nice way to start preparation for interview. Can you add more questions related to Exception handling, Collections etc. Looking forward for more, thanks!
ReplyDelete