Top Core Java Interview Questions and Answers

5.00 avg. rating (98% score) - 3 votes

Java is the most popular platform in today’s competitive world. Whether you are a fresher or highly experienced professional, Java opens up endless opportunities and benefits. Time is changing and so is the round of java interview. You can brush up your skills by choosing the most popular certification in Java. This article will give you a chance to do well in job interviews.

Here is the huge list of core java interview questions and answers that should be in your to do list before appearing for an interview.

Q1. What are the different types of memory areas allocated by JVM?


  • Stack
  • Class
  • Program counter register
  • Native method stack
  • Heap

Q2. What is a class loader?

Ans. It is a subsystem of JVM which is used to load interfaces and classes. Some of its examples are Extension classloader, pluginclassloader, Bootstrap classloader and extension classloader.

Q3. Define immutable objects?

Ans. Immutable objects are simply objects which can’t be modified once created.

Q4. What is the difference between StringBuilder and StringBuffer?

Ans. StringBuffer

  • Synchronized means two threads can’t call the methods of StringBuffer simultaneously
  • Less proficient than StringBuilder


  • Non-synchronized means two threads can call the threads of StringBuilder simultaneously
  • More efficient than StringBuffer

Q5. Which are the four principle concepts upon which object oriented design and programming rest?


  • Encapsulation
  • Abstraction
  • Polymorphism
  • Inheritance

Q6. What do you mean by loops?

Ans. Loop is used in programming to execute a statement or a block of statement repeatedly.

Q7. How can you prevent a method from being overridden?

Ans. Use the final modifier on the method declaration to prevent a method from being overridden.

Public final void examplemethod ()


// method statements


Q8. Is it necessary to create an object for an interface?

Ans. Yes.

Q9. Give an example of ternary operator?

Ans. Public class conditiontest


Public static void main (string args [])


String status;

Int rank;

Status= (rank ==1) “Done”: “Pending”;



Q10. Name the modifiers allowed for methods in an interface?

Ans. Public and abstract modifiers.

Q11. What do you mean by super?

Ans. It is a keyword used to access the method variables from the superclass.

Q12. When should we use abstract classes?

Ans. We use interfaces when something in our design will change frequently.

Q13. What is the base class of all classes?

Ans. Java.lang.object

Q14. Define a constant variable?

Ans. A constant variable should be declared as final and static. Eg:

Static final int MAX_LENGTH=50;

Q15. How can you implement singleton pattern?

Ans. You can implement singleton pattern by following common concepts which are:

  • Private static variable of the same class that is the only instance of the class
  • Private constructor to restrict instantiation of the class from other classes
  • Public static method that returns the instance of the class

Q16. Give one difference between continue and break statement?

Ans. Continue statement is used to end the current loop iteration while when break statement is used inside a loop, loop gets terminated and return at the next statement.

Q17. What do you understand by thread safe?

Ans. It is simply the program that behaves correctly when multiple simultaneous threads are using a resource.

Q18. What is the use of default constructor?

Ans. Constructor is used to initialize the object. Eg:

Class Bike1




System.out.println(“Bike is created”);


Public static void main(string args[])


Bike1 b= new Bike1();



Q19. Can you make a constructor final?

 Ans. No

Q20. What is object cloning?

Ans.  It is a way to create exact copy of an object. Clone() is defined in the object class.

Q21. Which package is imported by default?

Ans. Java.lang package is imported by default.

Q22. Can non-static variable be accessed in static context?

Ans. No.

Q23. Can you make an array volatile?

Ans. Yes, you can make an array volatile but only the reference which is pointing an array.

Q24. Which operator is considered to be with highest precedence?

Ans. Postfix operators.

Q25. What is the advantage of Encapsulation?

Ans. Themain advantage is the ability to modify implemented code without breaking the code of others.

Q26. Can a source file have more than one class declaration?

Ans. Yes, a source file can have more than one class declaration.

Q27. What is the difference between throw and throws?

Ans. Throw is used to trigger an exception while throws is used in declaration of exception.

Q28. What is JAR file?

Ans. JAR (Java Archive files) holds java classes in a library.

Q29. Define JIT compiler?

Ans. JIT (just-in time compiler) is enabled by default and is activated when a java method is called.

These are some of the frequently asked core Java interview questions and answers. What you say will make a big difference whether or not you get through a job interview. Be confident, energetic and happy!

Browse Courses by Categories

About the Author

Twinkle kapoor

Though from a techie background, her interest in writing on plethora of topics has made her today an experienced writer. She has written articles, blogs and web page content for oodles of websites.
Topics : IT and Telecom