0% found this document useful (0 votes)
7 views2 pages

Java_Interview_QA

java interview questions answer
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)
7 views2 pages

Java_Interview_QA

java interview questions answer
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
You are on page 1/ 2

Java Interview Questions & Answers

Q: What is Java?
A: Java is a high-level, object-oriented programming language developed by Sun Microsystems
(now owned by Oracle). It is platform-independent because of the JVM (Java Virtual Machine).

Q: What are the main features of Java?


A: Java is simple, object-oriented, platform-independent, secure, multithreaded, robust, and has
automatic memory management (Garbage Collection).

Q: What is JVM, JDK, and JRE?


A: JVM (Java Virtual Machine) runs Java programs. JRE (Java Runtime Environment) provides
libraries + JVM for running Java programs. JDK (Java Development Kit) includes JRE + tools for
development (like compiler).

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


A: == is used to compare references (memory location). .equals() is used to compare values
(content).

Q: What is the difference between Array and ArrayList?


A: Array has fixed size, can store primitive data types and objects. ArrayList is dynamic (resizable)
and stores only objects.

Q: What is the difference between final, finally, and finalize()?


A: final → keyword to make variable constant, method not overridable, or class not inheritable.
finally → block used in exception handling, always executes. finalize() → method called by Garbage
Collector before destroying an object.

Q: What are constructors in Java?


A: A constructor is a special method used to initialize objects. It has the same name as the class
and does not return anything.

Q: What is method overloading and overriding?


A: Overloading → Same method name but different parameters (compile-time polymorphism).
Overriding → Subclass provides its own implementation of a method defined in parent class
(runtime polymorphism).

Q: What is an interface in Java?


A: An interface is a collection of abstract methods (from Java 8 onwards, it can have default and
static methods too). It is used for abstraction and multiple inheritance.
Q: What is the difference between abstract class and interface?
A: Abstract class can have both abstract and non-abstract methods, supports single inheritance.
Interface can only have abstract methods (before Java 8), supports multiple inheritance.

Q: What is exception handling in Java?


A: Exception handling is a mechanism to handle runtime errors so that normal flow of the program
is maintained. It uses try, catch, finally, throw, and throws keywords.

Q: What is multithreading in Java?


A: Multithreading means executing multiple tasks simultaneously. It improves CPU utilization. In
Java, it can be achieved by extending Thread class or implementing Runnable interface.

Q: What is the difference between HashMap and Hashtable?


A: HashMap is not synchronized, allows one null key and multiple null values. Hashtable is
synchronized, does not allow null key or null values.

Q: What are Lambda Expressions?


A: Lambda expressions (introduced in Java 8) provide a way to write short code using functional
style. They are used mainly for implementing functional interfaces.

Q: What are Streams in Java?


A: Streams (Java 8) are used for processing collections in a functional style. They support
operations like filter, map, reduce, etc.

You might also like