0% found this document useful (0 votes)
2 views3 pages

Java Interview Questions Answers

The document contains a compilation of Java interview questions and answers covering various topics such as Core Java, Object-Oriented Programming, Collections & Data Structures, Exception Handling, Multithreading, Java 8 features, Spring Framework, and Hibernate ORM. Key concepts include differences between JDK, JRE, and JVM, exception handling mechanisms, and the use of lambda expressions and the Stream API. It also outlines the Spring Framework's components and Hibernate's functionalities.

Uploaded by

pranavi.yarram
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java Interview Questions Answers

The document contains a compilation of Java interview questions and answers covering various topics such as Core Java, Object-Oriented Programming, Collections & Data Structures, Exception Handling, Multithreading, Java 8 features, Spring Framework, and Hibernate ORM. Key concepts include differences between JDK, JRE, and JVM, exception handling mechanisms, and the use of lambda expressions and the Stream API. It also outlines the Spring Framework's components and Hibernate's functionalities.

Uploaded by

pranavi.yarram
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Interview Questions and Answers

Core Java

Q: What are the features of Java?

A: Object-Oriented, Platform Independent, Simple, Secure, Robust, Portable, Multithreaded, High

Performance.

Q: What is the difference between JDK, JRE, and JVM?

A: JDK: Tools + JRE for development. JRE: JVM + libraries for running Java apps. JVM: Executes bytecode.

Q: What is the difference between == and .equals()?

A: '==' checks reference equality, '.equals()' checks value/content equality.

Q: What are the data types in Java?

A: Primitive: byte, short, int, long, float, double, char, boolean. Non-Primitive: Strings, Arrays, Classes,

Interfaces.

Object-Oriented Programming

Q: What are the four pillars of OOP in Java?

A: Encapsulation, Inheritance, Polymorphism, Abstraction.

Q: What is method overloading and overriding?

A: Overloading: Same method name, different parameters. Overriding: Subclass modifies superclass method.

Q: What is the difference between abstract class and interface?

A: Abstract class: Can have implementations and variables. Interface: Only method declarations (till Java 7).

Collections & Data Structures

Q: Difference between ArrayList and LinkedList?

A: ArrayList: Fast random access, slow insertion/deletion. LinkedList: Fast insertion/deletion, slow access.

Q: Difference between HashMap and Hashtable?

A: HashMap: Not synchronized, allows one null key. Hashtable: Synchronized, no nulls allowed.

Exception Handling

Q: What is exception handling in Java?

A: Mechanism to handle runtime errors using try, catch, finally, throw, throws.
Java Interview Questions and Answers

Q: Difference between Checked and Unchecked exceptions?

A: Checked: Compile-time (IOException). Unchecked: Runtime (NullPointerException).

Multithreading

Q: How do you create a thread in Java?

A: 1. Extend Thread class. 2. Implement Runnable interface.

Q: Difference between synchronized and volatile?

A: Synchronized: Locks for thread safety. Volatile: Ensures visibility across threads.

Java 8 and Beyond

Q: What are lambda expressions?

A: Used to implement functional interfaces. Syntax: (params) -> expression.

Q: What is the Stream API?

A: Processes collections in a functional style using map, filter, reduce.

Q: What are default methods in interfaces?

A: Methods in interfaces with default implementation (Java 8+).

Spring Framework

Q: What is Spring Framework?

A: Open-source framework for building Java enterprise applications.

Q: Difference between @Component, @Service, @Repository?

A: @Component: Generic stereotype. @Service: Business logic. @Repository: DAO layer.

Q: What is Dependency Injection?

A: Design pattern where dependencies are injected by the container (Spring IOC).

Hibernate ORM

Q: What is Hibernate?

A: ORM framework for mapping Java classes to database tables.

Q: What is the difference between get() and load()?

A: get(): Returns null if not found. load(): Throws exception.


Java Interview Questions and Answers

Q: What is HQL?

A: Hibernate Query Language - object-oriented query language.

You might also like