Easy way to IT Job

Share on your Social Media

Top 20+ Core Java Interview Questions and Answers

Published On: May 28, 2024

Core Java Interview Questions and Answers

Anyone aspiring to be successful in software development must master Core Java. This article has 20+ core Java interview questions and answers useful for freshers and experienced professionals.

Core Java Interview Questions and Answers for Freshers

1. What is Java?

Java is a programming language that is robust, secure, object-oriented, high-level, platform-independent, multithreaded, and portable. James Gosling developed it in June of 1991. Because it offers its own JRE and API, it is frequently referred to as the platform.

2. Why isn’t Java an object-oriented language in its purest form?

Java is not a strictly object-oriented language since it allows primitive data types such as byte, boolean, char, short, int, float, long, and double.

3. If so, how is the Java platform independent?

Yes, Java is a platform-independent language. 

  • The Java compiler, in contrast to many other programming languages, converts the program into a bytecode or.class file. 
  • This file runs independently of any hardware or software, but to continue executing the bytecode, the operating system must have a JVM (Java Virtual Machine) file preloaded.
  • Java is platform agnostic even though the JVM is platform-dependent because the bytecode may be written on any system and executed on any other system regardless of the hardware or software being utilized.

4. What are the best features of Java?

One of the most well-known and widely used programming languages in the real world is Java. Its many advantages over other languages include its simplicity, platform independence, interpretability, robustness, object orientation, security, high performance, dynamic nature, distributed programming, multithreading, and architect neutrality. 

5. What is JVM?

The Java Virtual Machine, or JVM for short, is an interpreter for Java. It is in charge of loading, confirming, and running the Java bytecode.

While the JVM’s software varies depending on the operating system, it is platform-dependent, yet it is essential to making the Java platform independent.

6. What is JIT?

The Java Runtime Environment (JRE) includes the Just-in-Time (JIT) compiler, which is used to improve Java applications’ runtime performance.

7. What is a classloader?

The classloader is a component of the Java Runtime Environment (JRE) that is used for creating or executing bytecode.Java classes and interfaces are dynamically loaded into the Java Virtual Machine (JVM) using the class file classloader. The Java runtime system does not require knowledge of files or file systems because of classloaders.

8. What is Java String Pool?

A Java String Pool is a heap memory location that holds all of the program’s declared strings. On a stack, the variable containing the string is stored in a different place. 

Every time we create a new string object, the Java Virtual Machine (JVM) first determines whether the object already exists in the string pool. If it does, the object reference is shared with the variable; if not, a new object is produced.

9. What do Java packages mean?

Java packages are collections of related classes, interfaces, etc. that give access to namespace management and protection.

10. Why are packages utilized?

Java uses packages to manage access, avoid naming conflicts, and facilitate finding and using classes, interfaces, and other components.

11. What benefits do Java packages offer?

Determining packages in Java has several benefits:

  • Packages keep names apart.
  • The package facilitates easy access control.
  • We can have hidden classes that the package uses but are hidden from view.
  • Finding the associated classes is simpler.

12. In Java, how many different kinds of packages are there?

In Java, there are two types of packages, such as user-defined packages and build In packages

13. When does one use the byte datatype?

An 8-bit signed two-complement integer is called a byte. Bytes support a minimum of -128 and a maximum of 127 values. It is employed in situations where memory conservation is required and the range of values required is -128 to 127.

14. Can we use Java to declare a pointer?

No, Java does not offer pointer support. Due to Java’s lack of support for the pointer capability, the language needed to be more secure.

15. What is the Java byte datatype’s default value?

In Java, the byte datatype has a default value of 0.

16. What are the float and double datatypes’ default values in Java?

In Java, the default value for a double is 0.0d and for a float is 0.0f.

17. Why are wrapper classes necessary?

We require the primitive data types, which are encapsulated in the wrapper class, an object class, for the following reasons:

  • Wrapper classes are unchangeable and final.
  • It offers functions such as parseInt() and valueOf().
  • It can auto-box and un-box items. 

18. By default, what value is retained in local variables?

Local variables don’t have a default value saved in them. Furthermore, primitive objects and variables have no default values.

19. What is a static variable?

To share a class’s identical variable or method, use the static keyword. Static variables are those that, once declared, are created in a single copy and are shared among every object in the class.

20. Which classes are the most popular across all streams?

ByteStream classes and CharacterStream classes are the two categories into which all stream classes can be separated. 

  • There are two subclasses of the ByteStream classes: InputStream classes and OutputStream classes. 
  • Writer and Reader classes are further divisions inside CharacterStream classes. 
  • Java.io.InputStream and java.io.OutPutStream are the SuperMost classes for all input stream classes and output stream classes, respectively. 
  • Similarly, java.io.Reader is the super-most class for all reader classes, and java.io.Writer is the super-most class for all writer classes.

Core Java Interview Questions and Answers for Experienced Professionals

21. How do FilterStreams work?

A stream filter, also called a filter stream, returns a stream composed of the stream’s items that satisfy the given predicate.

Instead of truly filtering, functioning filter() generates a new stream that, upon traversal, contains the items of the initial streams that satisfy the supplied predicate.


FileInputStream fis =new FileInoutStream(“file_path”); 

FilterInputStream = new BufferedInputStream(fis);

22. Describe the distinction between the operators >> and >>>.

While they appear to be the same, operators like >> and >>> behave slightly differently. The sign bits are shifted using the >> operator, and the zero-filled bits are shifted out using the >>> operator. 


import java.io.*;

class GFG {

    public static void main(String[] args)


        int a = -16, b = 1;

        System.out.println(a >> b);

        a = -17;

        b = 1;

        System.out.println(a >>> b);






23. What makes StringBuffer mutable?

The Java StringBuffer class represents a dynamic string of characters. It allows you to edit a string’s contents without continuously creating new objects, which makes it an alternative to the immutable String class. 

The StringBuffer class is used to produce mutable (modifiable) strings. Except for being modifiable, the Java StringBuffer class is the same as the String class.

public class StringBufferExample {

    public static void main(String[] args)


        StringBuffer s = new StringBuffer();




        String message = s.toString();





SLA for Success

24. What distinguishes the production of a String with new() from that of a literal?

When we declare a string using new(), it creates a dynamic memory in the heap memory, as opposed to when we declare a literal, which stores the elements inside the stack memory. 

Even if there is already a copy of the content object, the object is generated in heap memory.


String x = new String(“ABC”);

25. What does the term “jagged array” mean to you?

In Java, a jagged array is simply a two-dimensional array where the lengths of its rows might vary. A jagged array gives you more freedom in terms of each row’s size than a 2-dimensional array because each row in the latter has the same length. 

When memory consumption needs to be optimized or when data has different durations, this capability comes in quite handy.   


int[][] Arr = new int[][] {

    {1, 2, 8}, 

    {7, 5}, 

    {6, 7, 2, 6}



Try these frequently asked core Java interview questions and answers and gain expertise with the fundamentals of Java. Join our Core Java Training in Chennai to get started with software developer jobs.

Share on your Social Media

Just a minute!

If you have any questions that you did not find answers for, our counsellors are here to answer them. You can get all your queries answered before deciding to join SLA and move your career forward.

We are excited to get started with you

Give us your information and we will arange for a free call (at your convenience) with one of our counsellors. You can get all your queries answered before deciding to join SLA and move your career forward.