Java technical interview questions

Java tricky interview questions

In this post, we will see top Java technical interview asked in the Core Java interview.I have covered a lot of interview question on Java programming.
Here is list of other java interview question you might find useful.

Here is the list of top 10 Java technical interview questions.

1 How HashMap works in java?

This is most asked interview question in java interview. You need to have understanding of internal working of HashMap to answer this questions.

You can refer How HashMap works in java for details.

2 Which methods you should implement for key Object in HashMap?

You need to implement Hashcode and equals method for Key object in HashMap.

You can refer Hashcode and equals method for details.

3. Guess the output of below program.

Main class

4. Guess the output of below code.

What will be output of above program.

5. What are differences between Comparator and Comparable?

Comparable and Comparator are used to sort list of object.

Please refer to the difference between Comparator and Comparable for details.

6. What is difference between Error and Exception?

Both java.lang.Error and java.lang.Exception classes are sub classes of java.lang.Throwable class.
You can not recover from Error but you can recover from Exception from using try catch block.
Examples for Errors are: java.lang.StackOverflowError, java.lang.OutOfMemoryError
Examples of Exceptions are: IOException, NullPointerException.

7. What is ClassLoader in java?

ClassLoader is the program that loads byte code class to memory whenever you want to need it.

8. What are types of ClassLoader in java?

There are three types of Class Loader in java.

Bootstrap class loader: It loads classes related to Java platform.
Extension class loader: Here the classes which will use Java extension mechanism will be loaded. These classes will reside in extensions directory as .jar files.
Application class loader: these classes are defined by users. These classes will be found by using class path variable.

9. Are you aware of Singleton design pattern? Can you create a Singleton class?

Singleton means you can create only one instance of that class.You can create a static method which will give you singleton object and you can make constructor private to restrict more than one object for below class.
This is a very basic version of Singleton class and there are various concepts such as Serialization,multithreading which can break below Singleton class.

10. What is the difference between Statement and PreparedStatement?

Statement : is used to execute normal SQL queries.You can not pass parameters to Statement.
PreparedStatement : PreparedStatement is used to execute dynamic or parameterized queries.PreparedStatement extends Statement.If you are going to execute queries multiple queries then you should use PreparedStatement as PreparedStatement are precompiled and query plan is executed only once no matter how many time you will execute the query.

That’s all about Java technical Interview questions.

Related Posts

  • Hibernate interview questions
    16 April

    Top 40+ Hibernate interview questions and answers

    Table of Contents1. What is ORM?2. What is Hibernate?3. What are advantages of Hibernate?4. Explain architecture of Hibernate?5. What are some core interfaces of hibernate?6. Explain brief about Session interface used in hibernate?7. Are session objects thread safe?8. Explain brief about SessionFactory object used in hibernate?9. What is Configuration class in hibernate?10. Explain brief about […]

  • Java Interview questions
    22 May

    Java interview questions

    Table of ContentsCore JavaCore java interview questionsCollections interview questionsMultithreading interview questionsJava 8 interview questionsOOPs interview questionsException Handling interview questionsString interview questionsSerialization interview questionsmethod overloading and method overriding interview questionsImmutable class interview questionsJava tricky interview questions Basic interview questions for fresher Interview questions for 5 to 7 years experiencedHow HashMap works in java? Difference between Interface […]

  • Solid principles in java
    09 November

    SOLID Principles in Java

    Table of ContentsWhat is the meaning of S.O.L.I.D?Single Responsibility Principle (SRP)Open Closed Principle Liskov Substitution Principle Interface Segregation PrincipleDependency Inversion PrincipleWrap Up In this post, we will see 5 SOLID Principles in Java. Robert C. Martin gave five objected oriented design principles, and the acronym S.O.L.I.D is used for it. Each letter of this acronym […]

  • Java interview questions for 2 years experience
    08 November

    Java interview questions for 2 years experience

    Table of Contents1.   Can we override static method in java?2.   Can you overload main method in java?3. Can we override private methods in java?4. What is the base class for all the classes?5.   Can you list down some of important method from object class?6.   Which two methods should you override while putting the custom object as […]

  • Java interview questions for 5 years experience
    08 November

    Java interview questions for 5 years experience

    Table of Contents1. Guess the output of below program.2. Guess the output of below program.3. Guess the output of below program.4. What will happen in case of below program?5. What will happen in case of below program?6. What will happen in case of below program?7. Guess the output of below program.8. Guess the output of […]

  • Spring Boot Interview questions
    06 August

    Spring boot interview questions for 10 years experience

    Table of Contents1. What is Spring boot?2. Why did you use Spring boot in your application?3. Can you list advantages of Spring boot?4. What are disadvantages of Spring boot?5. How can you override default properties in Spring boot Project?5. How can you run Spring boot application on custom port?6. What is Spring boot starter and how […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.