Looking for Core Java interview questions? Ee page lo neeku interview lo vastunna most important questions + short, clear answers untayi.
These questions cover: Java basics, OOPs, Collections, Exception Handling, JVM, Multithreading, Java 8 and real-time concepts. You can read this page 2–3 times before interview – chalu, good confidence vastundi.
1. Core Java Basics
Q1) What is Core Java?
Answer: Core Java is the fundamental part of Java used for building general-purpose applications. It includes OOP concepts, collections, exceptions, multithreading, and basic libraries like java.lang, java.util, and java.io.
Q2) What are the main features of Java?
Answer: Main features: Simple, Object-Oriented, Platform Independent (Write Once Run Anywhere), Secure, Robust, Multithreaded, High Performance (with JIT), and Distributed.
Q3) What is the difference between JDK, JRE, and JVM?
Answer:
- JVM – Java Virtual Machine that runs Java bytecode.
- JRE – JVM + core libraries to run Java applications.
- JDK – JRE + development tools (like
javac) to develop & compile Java applications.
Q4) What is bytecode in Java?
Answer: Bytecode is an intermediate code generated by the Java compiler. It is platform-independent and executed by the JVM on any operating system.
Q5) Why is Java platform independent?
Answer: Java is platform independent because the compiler generates bytecode (.class file), and the JVM is available for different OS. Same bytecode can run on any OS with a compatible JVM.
2. OOP Concepts in Java
Q6) What are the main OOP principles in Java?
Answer: Encapsulation, Inheritance, Polymorphism, and Abstraction.
Q7) What is the difference between a class and an object?
Answer: A class is a blueprint or template, and an object is a real-time instance of that class created in memory.
Q8) What is method overloading and overriding?
Answer:
- Overloading – Same method name, different parameter list, in the same class.
- Overriding – Same method signature in parent and child class, used to provide specific implementation in subclass.
Q9) What is an abstract class?
Answer: An abstract class is a class that cannot be instantiated and can have abstract (without body) and non-abstract methods. It is used to provide a base for subclasses.
Q10) Difference between interface and abstract class?
Answer:
- Interface supports multiple inheritance; abstract class does not.
- Interface methods are public and abstract by default (until Java 7); abstract class can have any access modifiers.
- Abstract class can have instance variables; interface generally has constants.
3. String, Memory & Wrapper Classes
Q11) Why is String immutable in Java?
Answer: String is immutable for security, caching, and performance. Once created, its value cannot be changed, which is safe for use in String pool, class loading, and collections.
Q12) Difference between == and equals() in Java?
Answer:
==compares references (memory addresses).equals()compares content (overridden in classes like String, Wrapper classes).
Q13) What is the String pool?
Answer: String pool is a special memory area in the heap where String literals are stored and reused to save memory.
Q14) What are wrapper classes in Java?
Answer: Wrapper classes are object representations of primitive types, like Integer, Double, Boolean. They are used with collections, generics, and APIs that work with objects only.
4. Collections Framework
Q15) What is the Java Collections Framework?
Answer: It is a set of classes and interfaces in java.util package to store and manipulate groups of objects, like List, Set, Map, etc.
Q16) Difference between List and Set?
Answer:
- List – Ordered collection, allows duplicate elements. Example:
ArrayList,LinkedList. - Set – Unordered (or sorted) collection, does not allow duplicates. Example:
HashSet,TreeSet.
Q17) Difference between ArrayList and LinkedList?
Answer: ArrayList is good for fast random access (index-based) and less for insert/delete in middle. LinkedList is better for frequent insert/delete operations in the middle but slower for random access.
Q18) Difference between HashMap and Hashtable?
Answer:
- HashMap – Not synchronized, allows one null key and multiple null values, faster.
- Hashtable – Synchronized, does not allow null key or value, slower, legacy class.
Q19) What is the difference between fail-fast and fail-safe iterators?
Answer: Fail-fast iterators (like in ArrayList, HashMap) throw ConcurrentModificationException if collection is modified during iteration. Fail-safe iterators (like in CopyOnWriteArrayList) work on a copy of the collection and do not throw this exception.
5. Exception Handling
Q20) What is an exception in Java?
Answer: An exception is an unwanted event that occurs during program execution, which disrupts the normal flow of the program.
Q21) Difference between checked and unchecked exceptions?
Answer:
- Checked – Checked at compile time, must be handled using
try-catchor declared usingthrows. Example:IOException,SQLException. - Unchecked – Subclasses of
RuntimeException, checked only at runtime. Example:NullPointerException,ArrayIndexOutOfBoundsException.
Q22) What is the difference between throw and throws?
Answer: throw is used to explicitly throw an exception from a method; throws is used in method signature to indicate that the method may throw that exception.
Q23) What is the difference between final, finally, and finalize()?
Answer:
- final – Keyword used with variable (constant), method (cannot override), class (cannot extend).
- finally – Block that always executes after
try-catch, used for cleanup code. - finalize() – Method called by garbage collector before object is destroyed (not guaranteed when).
6. JVM, Memory & Multithreading
Q24) What is the JVM architecture?
Answer: JVM architecture includes class loader subsystem, runtime data areas (heap, stack, method area, PC registers), and execution engine (interpreter, JIT compiler, garbage collector).
Q25) What is garbage collection in Java?
Answer: Garbage collection is the process by which JVM automatically removes unused objects from heap memory to free space.
Q26) What is a thread in Java?
Answer: A thread is a lightweight unit of a process. Java allows multiple threads to run concurrently to perform tasks in parallel.
Q27) How do you create a thread in Java?
Answer: Two common ways:
// 1) Extending Thread
class MyThread extends Thread {
public void run() {
System.out.println("Thread running...");
}
}
// 2) Implementing Runnable
class MyRunnable implements Runnable {
public void run() {
System.out.println("Thread running...");
}
}
Q28) What is the use of the synchronized keyword?
Answer: synchronized is used to control access to a shared resource in a multithreaded environment, preventing race conditions by allowing only one thread at a time to execute a block or method.
7. Java 8 Features
Q29) What are the key features of Java 8?
Answer: Lambda expressions, functional interfaces, Stream API, default and static methods in interfaces, new Date and Time API (java.time), Optional class.
Q30) What is a lambda expression?
Answer: A lambda expression is a short block of code which takes parameters and returns a value. It provides a clear and concise way to represent a function.
// Example: Lambda expression
List<String> names = Arrays.asList("A", "B", "C");
names.forEach(n -> System.out.println(n));
Q31) What is a functional interface?
Answer: A functional interface is an interface with exactly one abstract method. Example: Runnable, Callable, Comparator. In Java 8, they can be annotated with @FunctionalInterface.
Q32) What is the Stream API?
Answer: Stream API is used to process collections of objects in a functional style using operations like filter(), map(), reduce(), improving readability and performance.
8. Quick Revision Points Before Interview
- JDK vs JRE vs JVM
- OOPs pillars: Encapsulation, Inheritance, Polymorphism, Abstraction
- String immutability & String pool
- List vs Set, HashMap vs Hashtable
- Checked vs unchecked exceptions
final,finally,finalize()difference- Basic multithreading and
synchronized - Java 8: lambda, functional interface, Stream API
Ivi baga ardham chesukoni 2–3 sarlu chadavithe, Core Java interview lo majority questions cover avutayi.