Core Java interview questions and Answers

Last update: 08 Mar 2022, 30 Questions

Core Java, or Java Standard Edition (SE) is a computing platform for building standalone applications or system software. Using Java programming language, Core Java is a part of the Java software family. In Core Java, you will understand the basic Java programming concepts that are used in all classes from Java EE to desktop applications. Java SE also defines general-purpose APIs and includes Java Language Specification and Java Virtual Machine Specification. Oracle Corporation's Java Development Kit (JDK) is one of the most popular implementations of Java SE. You can now read our vast collection of latest core java interview questions.

Most Frequently Asked Core Java interview questions

Here in this article, we will be listing frequently asked Core Java interview questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

1. List some OOPS Concepts in Java?

In Java, there are 10 OOPS concepts as follows:

  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Association
  • Composition
  • Aggregation
  • Delegation
  • Coupling
  • Cohesion
8 0
2. List some important features of Java 10 release?

Here are some of the most important Java 10 features:

  • Local-Variable Type Inference
  • Consolidate the JDK Forest into a Single Repository
  • Garbage-Collector Interface
  • Parallel Full GC for G1
  • Application Class-Data Sharing
  • Thread-Local Handshakes
  • Heap Allocation on Alternative Memory Devices
  • Experimental Java-Based JIT Compiler
  • Root Certificates
  • Time-Based Release Versioning
4 1
3. What is JVM?

A part of Java Run Environment (JRE), JVM is a virtual machine that provides runtime environment to drive Java programs or applications. It assists in converting bytecode into machine language and handles system memory.

8 4
4. Explain the difference between JDK and JVM?
1. Stands for Java Development Kit Stands for Java Virtual machine
2. Provides environment for developing and running Java programs. Interprets byte code into the machine code
3. Includes development Tools Allows platform-independent coding
3 0
5. Explain the difference between JVM and JRE?
1. Provides runtime environment for Java apps and programs Stands for Java Runtime Environment
2. An integral part of JDK and JRE Provides an environment to run java programs only
3. Responsible for executing a java program Part of JRE distribution
2 0
6. Why does Java does not support multiple inheritance? Explain

Java does not support multiple inheritances because it may lead to overriding of methods when extended classes have the same method names.

Also, supporting multiple inheritances through classes may give rise to ambiguity errors. However, multiple inheritance is possible through the interface.

2 0
7. Why Java is called not pure Object Oriented language?

Java is not a pure OOP language as it uses primitive datatypes such as int float char double. A pure OOP language should use nothing but objects, and everything should be a class. But in Java, not everything is a class, such as byte, int, float, char, etc. This is the reason Java is a not a pure OOP language.

2 0
8. What is difference between classpath and path variables in Java?
  Classpath Path
1. Used to find path of classes Used to find executables
2. Refers to environment Refers to system
0 0
9. What is the purpose of main function in Java?

From version JDK6 onwards, the main method is mandatory to start code execution. If your program does not contain "main" method, you will get a run-time error. Please note that in the absence of "main" method your entire program will successfully compile but it will throw an error at runtime.

0 0
10. Explain access modifiers in Java.

Access modifiers help to restrict the scope of a class, variable, constructor, method or data.

Four types of access modifiers are available:

  • Default
  • Private
  • Protected
  • Public
0 0
11. What is static import in Java? Explain

The static import feature allows the static member of a class to be accessed directly without using the qualified name. The biggest advantage of this feature is that less coding will be required if you have access to a static member.

0 1
12. What is an interface in Java? Explain

It is a reference type that is similar to a class in Java. It is a collection of abstract methods that is used for full abstraction. An interface may have methods and variables but the methods in interface are abstract by default.

0 0
13. Explain the difference between abstract class and interface in Java?
  Abstract Class Interface
1. Can have members, constants, defined methods and method stubs Can only have methods stubs and constants
2. Methods and members can be defined with any visibility Methods must be defined as public
3. May contain non-final variables. Variables declared are by default final
0 0
14. What do you mean by Marker interface in Java?

It is an interfaces that has no field or methods (empty interface). It helps in conveying to the JVM that the class that is implementing the interface of a category will have special behavior. It is also known as tag interface.

There are 4 major marker interfaces:

  • Searilizable interface
  • Cloneable interface
  • Remote interface
  • ThreadSafe interface
0 0
15. What do you mean by Java Annotations?

Annotation is a tag in Java that represents metadata attached with a class, method, interface, or field. It provides supplement information to be used by compiler and JVM. Annotations do not change a compiled program's action and they are not pure comments.

If you are preparing for interviews, you can check core java interview questions and answers for more insight.

0 0
16. What do you mean by inner class in java? Explain

It is a class that is a member of another class.

There are 4 types of inner classes:

  • Nested Inner class
  • Method Local inner classes
  • Anonymous inner classes
  • Static nested classes
0 0
17. What do you mean by Classloader in Java?

Class loaders help in loading classes during runtime to the Java Virtual Machine. In addition, they are part of the Java Runtime Environment. Hence, due to class loaders, JVM is not required to know the underlying files for running programs.

0 0
18. List the different types of classloaders in java.

There are 3 types of built-in Class Loaders:

  • Bootstrap Class Loader: Loads internal classes
  • Extensions Class Loader: Loads classes from extensions directory
  • System Class Loader: Loads classes from the current classpath
0 0
19. What do you mean by default constructor in Java?

Java will automatically create default constructors if there are no default constructors written by you.

The default constructor will call parent default constructor and initialize member data variable to default values.

0 0
20. What do you mean by Garbage Collection used in Java?

It is the process through which Java programs perform memory management. When the Java programs run on JVM, objects get created in a part of the memory that is dedicated to program. When objects are no longer needed, the garbage collector finds and deletes them to free up program memory.

0 0
21. Explain Serialization and Deserialization in Java?

The process of converting an object into byte sequence that can be persisted to a disk or can be sent through streams is called Serialization.

The reverse process of Serialization, i.e. creating objects from a sequence of bytes is called deserialization.

0 0
23. Java is Pass by Value or Pass by Reference? Explain

Java is pass by value because variables are references and their value is passed to the methods.

This question was asked in a lot of latest core java interview questions.

0 0
24. Why we used break and continue statement in Java?

When the break statement is inside a loop, the loop gets terminated and the program resumes at the next statement after the loop.

The continue statement can be used in the loop control structure. It causes the loop to jump to the next iteration.

0 0
25. What do you mean by ternary operator in java?

It is the only conditional operator that can take three operands and assists in evaluating Boolean expressions. It is a replacement for if-then-else statement and is used a lot to replace the switch. Its goal s to decide what value should the variable be assigned.

0 0
26. What do you mean by composition in java?

It is the design technique for implementing has-a relationship in a class. You can use java inheritance or Object composition for reusing the code. You can achieve Java composition by using instance variables that are referring to other objects.

0 0
27. What is Encapsulation in Java? Explain

Encapsulation is one of the four OOP concepts. It is a way of wrapping variables and code on data as a single unit. The class variables are hidden from other classes, and can be accessed only through their current class. Therefore, this method is also called data hiding.

0 0
28. What is the difference between String, String Builder, and Buffer?
S.no String StringBuffer StringBuilder
1. Immutable Mutable Mutable
2. For logic operations, it is slow Thread-safe Faster and more efficient
3. Use it when immutable structure is required. Use it for creating mutable character sequence but string changes must be synchronized Use it for creating mutable character sequence
1 1
29. What are different access specifiers in Java? Explain

Java Access Specifiers regulate access to field, class, and method. Also called as visibility specifiers, they determine if a method or field can be used by another method in some other class. An important part of OOP, they are also used to restrict access.

There are four types of Access Specifiers:

  • Public
  • Private
  • Protected
  • Default
0 0
30. What do you mean by Ordered and Sorted in collections in Java?

In an ordered collection, the elements have a specific order, which is independent of the value. For example a List.

In the sorted collection, the collection has an order, and the order depends on the value of the element. For example a SortedSet.

Developers should know everything about core java programs before their next interview.

0 1

Development History

J2SE 1.2 was released in December 1998. Subsequent releases of J2SE were done over the years. It was after J2SE 5, in December 2006, Sun replaced "J2SE" with "Java SE" and removed ".0" from the version numbers.

Latest Version

Oracle released Java SE 11.0.1 in Oct 2018, which is the latest release for Java SE 11 Platforms. Get more knowledge on this if you are preparing for core java interview questions and answers.

Our updated core java interview questions for 6 years experience professionals are one of the biggest question bank available online.

About Best Interview Question
Best Interview Question
Technical Consultant

With our 10+ experience in PHP, MySQL, React, Python & more our technical consulting firm has received the privilege of working with top projects, 100 and still counting. Our team of 25+ is skilled in distinct programming languages such as Python, Java, React.js, Angular, Node.js, PHP, HTML, CSS, Designing, iOS and Android apps, Database, .net, QA, Digital Marketing and Govt. jobs, etc. We are helping 10+ companies in solving their technical problems. When not found coding, our technical consultants can be seen helping out others.