What is the default value of a boolean variable in Java?
false
What is the process of hiding internal details and showing only functionality called?
Abstraction
Which keyword is used to handle exceptions in Java?
try-catch
Which collection class does not allow duplicate elements?
HashSet
What symbol is used for lambda expressions?
->
Which keyword is used to define a constant in Java?
final
Which OOP principle allows a subclass to reuse methods of its superclass?
Inheritance
What is the parent class of all exceptions in Java?
Throwable
What does HashMap.putIfAbsent() do?
Inserts the key-value pair only if the key is not already present
What is the default method in interfaces?
A method with body in interface using default keyword
What will System.out.println(10 + 20 + "Java"); print?
30Java
Can an abstract class have a constructor in Java?
Yes
What is the difference between checked and unchecked exceptions?
Checked = checked at compile time; Unchecked = checked at runtime
What’s the difference between ArrayList and LinkedList?
ArrayList = faster for random access; LinkedList = faster for insert/delete in the middle
What does Optional class help with?
Avoiding null pointer exceptions
What is the size of an int in Java?
4 bytes (32 bits)
What’s the difference between method overloading and method overriding?
Overloading = same method name, different parameters; Overriding = redefining superclass method in subclass
What happens if an exception is not caught?
The program terminates abnormally
Can you use primitive data types with generics in Java?
No, but you can use wrapper classes like Integer, Double
How do you filter a list in Java 8?
Using stream().filter()
Which Java feature allows you to write platform-independent code?
Java Virtual Machine (JVM)
How do you achieve multiple inheritance in Java?
Through interfaces
Can you write finally block without a catch block?
Yes, with try-finally
How do you sort a List<String> alphabetically?
Collections.sort(list)
What is a functional interface?
An interface with only one abstract method (e.g., Runnable)