Docs LogoDocs
Interview PrepCognizant Interview

Core Java

Core Java interview questions for Cognizant.

Part II – Core Java (80 Questions)


A. Java Basics & Platform

1. What is JVM?

Answer: The Java Virtual Machine is an abstract machine that executes Java bytecode. It provides platform independence — the same .class file runs on any OS that has a compatible JVM.

Explanation: JVM handles class loading, bytecode verification, execution (via interpreter/JIT compiler), and memory management (heap, stack, garbage collection).

Follow-up: What are the main components of JVM? (Class Loader, Runtime Data Areas, Execution Engine)

Common Mistakes: Confusing JVM with JDK/JRE.

Interview Tip: Draw the JVM architecture diagram if given a whiteboard — it signals depth.


2. What is JDK?

Answer: Java Development Kit — a full development environment that includes the JRE plus development tools like javac (compiler), debugger, and javadoc.

Explanation: JDK = JRE + development tools. You need JDK to write and compile Java code, not just run it.

Follow-up: Can you run a .class file without JDK? (Yes, with just JRE)

Common Mistakes: Saying JDK is only for compiling — it also includes runtime.


3. What is JRE?

Answer: Java Runtime Environment — provides the libraries and JVM needed to run Java applications, but no compiler.

Explanation: JRE = JVM + core libraries (rt.jar pre-Java 9, or modules post-Java 9).

Follow-up: JDK vs JRE vs JVM — summarize in one line each.


4. What is bytecode?

Answer: Platform-independent intermediate code generated by javac from .java source files, stored in .class files, and executed by the JVM.

Explanation: Bytecode is what makes Java "write once, run anywhere" — the JVM interprets/JIT-compiles it into native machine code at runtime.

Follow-up: How is bytecode different from machine code?


5. Explain the Java compilation process

Answer: Source code (.java) → compiled by javac into bytecode (.class) → loaded by the ClassLoader → verified by the Bytecode Verifier → executed by the Execution Engine (interpreter + JIT compiler).

Explanation: JIT (Just-In-Time) compilation converts frequently-run bytecode into native machine code for performance.

Follow-up: What is JIT compilation and why does it matter?


B. Variables, Data Types & Operators

6. What are the types of variables in Java?

Answer: Instance variables (object-level), static/class variables (shared across all instances), and local variables (method-scoped).

Explanation: Each has different scope, default values, and lifetime. Local variables have no default value and must be initialized before use.

Follow-up: Do local variables get default values? (No)


7. What are Java's primitive data types?

Answer: byte, short, int, long, float, double, char, boolean — 8 total.

Explanation: These are stored by value, not reference, and have fixed sizes (e.g., int = 4 bytes, long = 8 bytes).

Follow-up: What's the default value of each primitive type?


8. Difference between primitive types and wrapper classes?

Answer: Primitives store raw values directly and live on the stack (in most cases); wrapper classes (Integer, Double, etc.) are objects that wrap primitives and live on the heap, enabling use in collections and allowing null.

Explanation: Autoboxing/unboxing automatically converts between the two.

Follow-up: What is the Integer cache (-128 to 127)?

Common Mistakes: Using == to compare wrapper objects instead of .equals().


9. What are operators in Java? Name the categories.

Answer: Arithmetic, relational, logical, bitwise, assignment, unary, ternary, and shift operators.

Follow-up: What does the >>> operator do differently from >>? (Unsigned right shift, fills with 0 regardless of sign)


10. Difference between == and .equals()?

Answer: == compares references (memory addresses) for objects, or values for primitives. .equals() compares logical/content equality, and can be overridden.

Explanation: For Strings, == may appear to work due to the String pool, but this is unreliable — always use .equals() for content comparison.

Follow-up: What happens with new String("a") == "a"? (false)

Common Mistakes: Using == for String comparison.


C. Control Statements, Arrays & Strings

11. What are the types of control statements in Java?

Answer: Decision-making (if, if-else, switch), looping (for, while, do-while), and jump statements (break, continue, return).


12. Difference between while and do-while?

Answer: while checks the condition before executing the loop body; do-while executes the body at least once before checking the condition.

Follow-up: Give a real use case where do-while is preferable (e.g., menu-driven programs).


13. What is an array in Java?

Answer: A fixed-size, ordered collection of elements of the same type, stored in contiguous memory, and indexed from 0.

Explanation: Arrays are objects in Java (they have a .length field, not .length()).

Follow-up: Can array size change after creation? (No — arrays are fixed size)


14. Difference between array and ArrayList?

Answer: Arrays have fixed size and can hold primitives directly; ArrayList is resizable, holds only objects (autoboxed primitives), and offers built-in methods like add(), remove().

Common Mistakes: Saying arrays are always slower — for fixed-size primitive data, arrays are actually faster.


15. Is String mutable or immutable in Java? Why?

Answer: Immutable. Once created, a String object's value cannot be changed — any modification creates a new object.

Explanation: Immutability enables the String pool (memory efficiency), thread safety, and safe use as HashMap keys.

Follow-up: How does StringBuilder differ from String? (Mutable, no pooling)


16. Difference between String, StringBuilder, and StringBuffer?

Answer: String is immutable. StringBuilder is mutable and not thread-safe (faster). StringBuffer is mutable and thread-safe (synchronized methods, slightly slower).

Follow-up: When would you choose StringBuffer over StringBuilder? (Multi-threaded context needing thread safety)


17. What is the String pool?

Answer: A special memory region in the heap where Java stores unique String literals to avoid duplicate objects and save memory.

Explanation: Strings created with new String() bypass the pool unless .intern() is called explicitly.


D. Object-Oriented Programming

18. What are the four pillars of OOP?

Answer: Encapsulation, Inheritance, Polymorphism, Abstraction.

Follow-up: Give a one-line Java example for each.


19. What is encapsulation?

Answer: Bundling data (fields) and methods that operate on it within a class, and restricting direct access to fields using access modifiers (typically private fields with public getters/setters).

Follow-up: How does encapsulation support data validation?


20. What is inheritance? What are its types in Java?

Answer: A mechanism where a class (subclass) acquires properties/behavior of another class (superclass) using extends. Java supports single, multilevel, and hierarchical inheritance directly; multiple inheritance of classes is not supported (only via interfaces).

Follow-up: Why doesn't Java support multiple inheritance of classes? (Diamond problem ambiguity)


21. What is polymorphism? What are its types?

Answer: The ability of an object to take multiple forms. Compile-time polymorphism (method overloading) and runtime polymorphism (method overriding via dynamic dispatch).

Follow-up: How does the JVM decide which overridden method to call at runtime? (Based on the actual object type, via the vtable/dynamic method dispatch)


22. What is abstraction? How is it achieved in Java?

Answer: Hiding implementation details and exposing only essential features. Achieved via abstract classes (partial abstraction) and interfaces (full abstraction, pre-Java 8).

Follow-up: Since Java 8, interfaces can have default methods — does that change the definition of abstraction?


23. Difference between abstract class and interface?

Answer: Abstract classes can have constructors, instance variables, and both abstract and concrete methods; a class can extend only one abstract class. Interfaces (pre-Java 8) had only abstract methods and constants; a class can implement multiple interfaces. Since Java 8+, interfaces can have default and static methods too.

Follow-up: When would you choose an abstract class over an interface?

Common Mistakes: Saying interfaces "can never have method bodies" — outdated since Java 8.


24. What is a constructor? What are its types?

Answer: A special method invoked when an object is created, used to initialize state. Types: default (no-arg, auto-generated if none defined), parameterized, and copy constructors (not built-in in Java but can be written manually).

Follow-up: Does a constructor have a return type? (No, not even void)


25. What is constructor overloading?

Answer: Defining multiple constructors in a class with different parameter lists, allowing objects to be initialized in different ways.

Follow-up: Can constructors be overridden? (No — they're not inherited)


26. What is the static keyword used for?

Answer: Marks a member (variable, method, block, or nested class) as belonging to the class itself rather than any instance — shared across all objects.

Follow-up: Can a static method access instance variables directly? (No)

Common Mistakes: Trying to call non-static methods from a static context without an object reference.


27. What is the final keyword used for?

Answer: final variable → value cannot be reassigned after initialization. final method → cannot be overridden. final class → cannot be extended (e.g., String).

Follow-up: Is a final object's internal state immutable? (Not necessarily — the reference is fixed, but the object's fields can still change unless the class itself is designed to be immutable)


28. What is the difference between this and super?

Answer: this refers to the current object instance; super refers to the immediate parent class, used to access parent constructors, methods, or fields.

Follow-up: Can this() and super() be used in the same constructor? (No — only one, and it must be the first statement)


29. What is method overloading?

Answer: Defining multiple methods with the same name but different parameter lists (number, type, or order) within the same class. Resolved at compile-time.

Follow-up: Can methods be overloaded by return type alone? (No)


30. What is method overriding?

Answer: Redefining a superclass method in a subclass with the same signature, enabling runtime polymorphism. Requires inheritance.

Explanation: Rules: same method signature, same or covariant return type, access modifier can't be more restrictive, and the @Override annotation is recommended (not mandatory) for compiler safety.

Follow-up: Can static methods be overridden? (No — they can be hidden, not overridden)

Common Mistakes: Confusing overloading (compile-time) with overriding (runtime).


31. What are access modifiers in Java?

Answer: private (class only), default/package-private (same package), protected (same package + subclasses), public (everywhere).

Follow-up: Can a top-level class be private? (No — only public or default)


32. What is a package in Java?

Answer: A namespace mechanism to organize related classes/interfaces and avoid naming conflicts. Also controls access via package-private visibility.

Follow-up: Difference between import and package statements?


E. Exception Handling

33. What is exception handling in Java?

Answer: A mechanism to handle runtime errors gracefully using try, catch, finally, throw, and throws, preventing abrupt program termination.

Follow-up: What is the class hierarchy for exceptions? (ThrowableException/Error → checked/unchecked)


34. Difference between checked and unchecked exceptions?

Answer: Checked exceptions (e.g., IOException) are checked at compile-time and must be declared or handled. Unchecked exceptions (e.g., NullPointerException, extending RuntimeException) are not checked at compile-time.

Follow-up: Give an example of each from the standard library.


35. Difference between throw and throws?

Answer: throw is used to explicitly throw a single exception instance inside a method body. throws is used in a method signature to declare exceptions the method might throw.

Common Mistakes: Mixing up the two in syntax questions.


36. What is the finally block? Does it always execute?

Answer: A block that runs after try/catch, used for cleanup (closing resources, etc.). It always executes except when the JVM exits via System.exit(), a fatal crash, or the thread is killed.

Follow-up: What happens if both try and finally have return statements? (finally's return wins — generally considered bad practice)


37. What is try-with-resources?

Answer: A Java 7+ syntax that automatically closes resources (implementing AutoCloseable) at the end of the block, removing the need for manual finally-based cleanup.

Follow-up: What interface must a resource implement to be used this way? (AutoCloseable/Closeable)


38. Can you catch multiple exceptions in one block?

Answer: Yes, using multi-catch syntax: catch (IOException | SQLException e), available since Java 7.

Follow-up: What's a limitation of multi-catch? (Caught exceptions can't have a subclass/superclass relationship)


39. What is a custom exception? How do you create one?

Answer: A user-defined exception class extending Exception (checked) or RuntimeException (unchecked), used to represent domain-specific error conditions.

Follow-up: When would you create a custom exception instead of using a built-in one?


40. What happens if an exception is not caught?

Answer: It propagates up the call stack; if uncaught anywhere, the JVM's default handler prints the stack trace and terminates the thread (or program, if it's the main thread).


F. Collections & Generics

41. What is the Java Collections Framework?

Answer: A unified architecture (interfaces + implementations) for storing and manipulating groups of objects — includes List, Set, Map, Queue, and their implementing classes.

Follow-up: Is Map part of the Collection interface hierarchy? (No — it's a separate hierarchy)


42. Difference between List, Set, and Map?

Answer: List — ordered, allows duplicates, index-based access. Set — no duplicates, mostly unordered (except LinkedHashSet/TreeSet). Map — key-value pairs, unique keys.

Follow-up: Which of these allows null keys/values, and how many?


43. Difference between ArrayList and LinkedList?

Answer: ArrayList uses a dynamic array — fast random access (O(1)), slower inserts/deletes in the middle (O(n)). LinkedList uses a doubly-linked list — slower random access (O(n)), faster inserts/deletes at known positions (O(1)).

Follow-up: Which would you use for a queue-like structure? (LinkedList, or ArrayDeque)


44. Difference between HashMap, LinkedHashMap, and TreeMap?

Answer: HashMap — no ordering guarantee, O(1) average access. LinkedHashMap — maintains insertion order. TreeMap — sorted by key (natural order or custom Comparator), O(log n) access.

Follow-up: How does HashMap handle collisions internally? (Chaining via linked list, converted to a red-black tree for large buckets since Java 8)


45. How does HashMap work internally?

Answer: Uses an array of buckets; each key's hashCode() determines the bucket index. Collisions within a bucket are handled via a linked list (or tree, if the bucket grows large). equals() is used to check key equality within a bucket.

Follow-up: What happens if hashCode() is overridden but equals() is not (or vice versa)?

Common Mistakes: Not understanding the hashCode/equals contract.


46. Difference between HashSet and TreeSet?

Answer: HashSet — no ordering, backed by a HashMap internally, O(1) average operations. TreeSet — sorted order, backed by a TreeMap, O(log n) operations.


47. What is the difference between Iterator and ListIterator?

Answer: Iterator allows forward-only traversal and element removal. ListIterator (List-specific) allows bidirectional traversal, element replacement, and addition.

Follow-up: Why use an Iterator instead of a for-each loop when removing elements? (Avoids ConcurrentModificationException)


48. What is ConcurrentModificationException?

Answer: A runtime exception thrown when a collection is structurally modified while being iterated (outside of the iterator's own remove method).

Follow-up: How can you safely remove elements while iterating? (Iterator.remove(), or CopyOnWriteArrayList for concurrent contexts)


49. What are Generics in Java?

Answer: A feature that allows types (classes, interfaces, methods) to be parameterized, enabling compile-time type safety and eliminating the need for explicit casting.

Follow-up: What is type erasure? (Generic type info is removed at runtime by the compiler)


50. What are bounded type parameters in generics?

Answer: Restricting the types that can be used as a generic parameter using extends (upper bound) — e.g., <T extends Number>.

Follow-up: What's the difference between <T extends Number> and <? extends Number>?


51. What are wildcards in generics?

Answer: ? represents an unknown type. ? extends T (upper bounded, read-only-ish), ? super T (lower bounded, write-friendly), and unbounded ?.

Follow-up: Explain PECS — "Producer Extends, Consumer Super."


G. Comparable & Comparator

52. Difference between Comparable and Comparator?

Answer: Comparable defines a class's natural ordering via compareTo(), implemented within the class itself. Comparator defines external, custom ordering via compare(), allowing multiple sort strategies for the same class.

Follow-up: Can you sort a List using both at once? Which takes precedence if passed explicitly?


53. How do you sort a list of custom objects?

Answer: Implement Comparable<T> on the class for a default sort order, or pass a Comparator to Collections.sort() / list.sort() for custom/alternate ordering.

Follow-up: How would you sort by multiple fields (e.g., name, then age)? (Comparator.comparing(...).thenComparing(...))


H. Multithreading & Synchronization

54. What is a thread in Java?

Answer: The smallest unit of execution within a process, allowing concurrent execution of code paths. Java supports multithreading via the Thread class and Runnable interface.

Follow-up: Difference between extending Thread vs. implementing Runnable? (Runnable is preferred — allows extending another class too, and separates task from execution mechanism)


55. What are the different states of a thread?

Answer: New, Runnable, Blocked, Waiting, Timed Waiting, and Terminated.

Follow-up: What causes a thread to move from Runnable to Blocked?


56. What is synchronization in Java?

Answer: A mechanism to control access to shared resources by multiple threads, preventing race conditions, using the synchronized keyword on methods or blocks.

Follow-up: What is a monitor lock/intrinsic lock?


57. Difference between synchronized method and synchronized block?

Answer: A synchronized method locks the entire method (on this or the class object for static methods). A synchronized block locks only a specific section of code on a specified object, offering finer-grained control and better performance.

Follow-up: Why is synchronized block generally preferred?


58. What is a deadlock? How can it be avoided?

Answer: A situation where two or more threads are blocked forever, each waiting on a lock held by the other. Avoided via consistent lock ordering, using timeouts (tryLock()), or minimizing nested locks.

Follow-up: Can you write pseudocode demonstrating a two-thread deadlock?


59. What is the difference between wait() and sleep()?

Answer: wait() (from Object) releases the lock and pauses until notified; must be called within a synchronized context. sleep() (from Thread) pauses the thread without releasing any lock it holds.

Follow-up: What wakes a thread from wait()? (notify() / notifyAll(), or interruption)


60. What is volatile keyword used for?

Answer: Ensures that a variable's value is always read from and written to main memory, not a thread's local cache — guarantees visibility (not atomicity) across threads.

Follow-up: Does volatile make compound operations like i++ thread-safe? (No)


I. Garbage Collection & Memory Management

61. What is garbage collection in Java?

Answer: The automatic process by which the JVM reclaims memory occupied by objects that are no longer reachable from any live thread or static reference.

Follow-up: Can you force garbage collection? (System.gc() is only a request, not a guarantee)


62. What are the different memory areas in JVM?

Answer: Heap (objects), Stack (method calls, local variables), Method Area/Metaspace (class metadata), PC Register, and Native Method Stack.

Follow-up: Where do static variables live? (Method Area/Metaspace)


63. What is the difference between the Young and Old generation in heap memory?

Answer: Young generation (Eden + Survivor spaces) holds newly created, short-lived objects, collected frequently via Minor GC. Old generation holds long-lived objects that survived multiple GC cycles, collected less frequently via Major/Full GC.

Follow-up: What triggers promotion from Young to Old generation?


64. What causes a memory leak in Java despite garbage collection?

Answer: When objects are still referenced (e.g., in a static collection, unclosed resources, or listener that's never deregistered) even though they're logically no longer needed — the GC can't reclaim them because they remain "reachable."

Follow-up: Give a real example of a memory leak pattern (e.g., growing static List never cleared).


J. Reflection, Serialization & File Handling

65. What is reflection in Java?

Answer: An API (java.lang.reflect) that allows inspecting and manipulating classes, methods, fields, and constructors at runtime, even private ones.

Follow-up: Give a real use case (e.g., frameworks like Spring using reflection for dependency injection).

Common Mistakes: Overusing reflection in application code — it bypasses compile-time checks and hurts performance.


66. What is serialization? How do you implement it?

Answer: Converting an object's state into a byte stream (for storage or transmission) by implementing the Serializable marker interface. Deserialization reverses the process.

Follow-up: What is serialVersionUID and why is it important?


67. What is transient keyword used for?

Answer: Marks a field to be excluded from the serialization process — its value is not saved and will default (e.g., null/0) upon deserialization.

Follow-up: Give a real use case (e.g., excluding a password field from serialization).


68. How do you read/write files in Java?

Answer: Using classes like FileReader/FileWriter (character streams), FileInputStream/FileOutputStream (byte streams), or higher-level utilities like BufferedReader, Files.readAllLines() (NIO), and Files.write().

Follow-up: What's the advantage of using BufferedReader over plain FileReader? (Reduces I/O calls by buffering)


K. Java 8 Features

69. What are the key features introduced in Java 8?

Answer: Lambda expressions, the Stream API, functional interfaces, default/static interface methods, Optional, and the new java.time date/time API.


70. What is a lambda expression?

Answer: A concise way to represent an anonymous function — an implementation of a functional interface — using the syntax (parameters) -> expression/body.

Follow-up: Why can lambdas only be used with functional interfaces (single abstract method)?


71. What is a functional interface?

Answer: An interface with exactly one abstract method (may have multiple default/static methods), enabling it to be implemented via a lambda expression. Marked optionally with @FunctionalInterface.

Follow-up: Name built-in functional interfaces (Function, Predicate, Supplier, Consumer).


72. What is the Stream API?

Answer: An API for processing sequences of elements (from collections, arrays, etc.) in a functional, declarative style, supporting operations like filter, map, reduce, and collect.

Follow-up: Difference between intermediate and terminal operations in streams?


73. Difference between map() and flatMap() in streams?

Answer: map() transforms each element into another single element (1-to-1). flatMap() transforms each element into a stream and flattens all resulting streams into one (1-to-many, flattened).

Follow-up: Give an example where flatMap is necessary (e.g., flattening a List<List<String>>).


74. What is Optional in Java? Why was it introduced?

Answer: A container object that may or may not hold a non-null value, used to explicitly represent "value may be absent" and reduce NullPointerException risk.

Follow-up: What's the difference between Optional.of() and Optional.ofNullable()?

Common Mistakes: Calling .get() on an Optional without checking .isPresent() first — defeats the purpose.


75. What is a method reference in Java 8?

Answer: A shorthand syntax for a lambda that simply calls an existing method — e.g., String::toUpperCase instead of s -> s.toUpperCase().

Follow-up: Name the four types of method references (static, instance of particular object, instance of arbitrary object, constructor).


76. What is the difference between intermediate and terminal stream operations?

Answer: Intermediate operations (filter, map, sorted) are lazy and return a new stream, allowing chaining. Terminal operations (collect, forEach, reduce) trigger actual execution and produce a result or side-effect.

Follow-up: Why are streams lazily evaluated? (Efficiency — avoids unnecessary processing until a terminal op is invoked)


77. What is the difference between Collection and Stream?

Answer: A Collection is a data structure that stores elements in memory; a Stream is a sequence of computations/operations over data, not a data structure itself, and doesn't store elements.

Follow-up: Can a stream be reused/traversed twice? (No — throws IllegalStateException)


78. What is the reduce() operation in streams?

Answer: A terminal operation that combines stream elements into a single result using an accumulator function — e.g., summing a list of integers.

Follow-up: Write a one-liner to sum a List<Integer> using reduce().


79. What are default and static methods in interfaces?

Answer: default methods provide a concrete implementation in an interface that implementing classes can inherit or override. static methods belong to the interface itself and are called via the interface name, not inherited by implementers.

Follow-up: Why were default methods introduced? (To evolve interfaces like Collection without breaking existing implementations)


80. What is the new Date/Time API introduced in Java 8?

Answer: The java.time package (LocalDate, LocalDateTime, ZonedDateTime, Duration, Period, etc.) — an immutable, thread-safe replacement for the old, mutable and error-prone java.util.Date/Calendar classes.

Follow-up: Why is immutability important for date/time objects? (Thread safety, predictability, no accidental mutation bugs)


End of Part II. Part III (Spring Boot, 40 questions) continues next.

Last updated on July 15, 2026

On this page

Part II – Core Java (80 Questions)A. Java Basics & Platform1. What is JVM?2. What is JDK?3. What is JRE?4. What is bytecode?5. Explain the Java compilation processB. Variables, Data Types & Operators6. What are the types of variables in Java?7. What are Java's primitive data types?8. Difference between primitive types and wrapper classes?9. What are operators in Java? Name the categories.10. Difference between == and .equals()?C. Control Statements, Arrays & Strings11. What are the types of control statements in Java?12. Difference between while and do-while?13. What is an array in Java?14. Difference between array and ArrayList?15. Is String mutable or immutable in Java? Why?16. Difference between String, StringBuilder, and StringBuffer?17. What is the String pool?D. Object-Oriented Programming18. What are the four pillars of OOP?19. What is encapsulation?20. What is inheritance? What are its types in Java?21. What is polymorphism? What are its types?22. What is abstraction? How is it achieved in Java?23. Difference between abstract class and interface?24. What is a constructor? What are its types?25. What is constructor overloading?26. What is the static keyword used for?27. What is the final keyword used for?28. What is the difference between this and super?29. What is method overloading?30. What is method overriding?31. What are access modifiers in Java?32. What is a package in Java?E. Exception Handling33. What is exception handling in Java?34. Difference between checked and unchecked exceptions?35. Difference between throw and throws?36. What is the finally block? Does it always execute?37. What is try-with-resources?38. Can you catch multiple exceptions in one block?39. What is a custom exception? How do you create one?40. What happens if an exception is not caught?F. Collections & Generics41. What is the Java Collections Framework?42. Difference between List, Set, and Map?43. Difference between ArrayList and LinkedList?44. Difference between HashMap, LinkedHashMap, and TreeMap?45. How does HashMap work internally?46. Difference between HashSet and TreeSet?47. What is the difference between Iterator and ListIterator?48. What is ConcurrentModificationException?49. What are Generics in Java?50. What are bounded type parameters in generics?51. What are wildcards in generics?G. Comparable & Comparator52. Difference between Comparable and Comparator?53. How do you sort a list of custom objects?H. Multithreading & Synchronization54. What is a thread in Java?55. What are the different states of a thread?56. What is synchronization in Java?57. Difference between synchronized method and synchronized block?58. What is a deadlock? How can it be avoided?59. What is the difference between wait() and sleep()?60. What is volatile keyword used for?I. Garbage Collection & Memory Management61. What is garbage collection in Java?62. What are the different memory areas in JVM?63. What is the difference between the Young and Old generation in heap memory?64. What causes a memory leak in Java despite garbage collection?J. Reflection, Serialization & File Handling65. What is reflection in Java?66. What is serialization? How do you implement it?67. What is transient keyword used for?68. How do you read/write files in Java?K. Java 8 Features69. What are the key features introduced in Java 8?70. What is a lambda expression?71. What is a functional interface?72. What is the Stream API?73. Difference between map() and flatMap() in streams?74. What is Optional in Java? Why was it introduced?75. What is a method reference in Java 8?76. What is the difference between intermediate and terminal stream operations?77. What is the difference between Collection and Stream?78. What is the reduce() operation in streams?79. What are default and static methods in interfaces?80. What is the new Date/Time API introduced in Java 8?