Java Basics
Object-Oriented Concepts (OOP)
Exception Handling
Collections & Generics
Java Features
100

What is the default value of a boolean variable in Java?

false

100

What is the process of hiding internal details and showing only functionality called?

Abstraction

100

Which keyword is used to handle exceptions in Java?

try-catch

100

Which collection class does not allow duplicate elements?

HashSet

100

What symbol is used for lambda expressions?

->

200

Which keyword is used to define a constant in Java?

final

200

Which OOP principle allows a subclass to reuse methods of its superclass?

Inheritance

200

What is the parent class of all exceptions in Java?

Throwable

200

What does HashMap.putIfAbsent() do?

Inserts the key-value pair only if the key is not already present

200

What is the default method in interfaces?

A method with body in interface using default keyword

300

What will System.out.println(10 + 20 + "Java"); print?

30Java

300

Can an abstract class have a constructor in Java?

Yes

300

What is the difference between checked and unchecked exceptions?

Checked = checked at compile time; Unchecked = checked at runtime

300

What’s the difference between ArrayList and LinkedList?

ArrayList = faster for random access; LinkedList = faster for insert/delete in the middle

300

What does Optional class help with?

Avoiding null pointer exceptions

400

What is the size of an int in Java?

4 bytes (32 bits)

400

What’s the difference between method overloading and method overriding?

Overloading = same method name, different parameters; Overriding = redefining superclass method in subclass

400

What happens if an exception is not caught?

The program terminates abnormally

400

Can you use primitive data types with generics in Java?

No, but you can use wrapper classes like Integer, Double

400

How do you filter a list in Java 8?

Using stream().filter()

500

Which Java feature allows you to write platform-independent code?

Java Virtual Machine (JVM)

500

How do you achieve multiple inheritance in Java?

Through interfaces

500

Can you write finally block without a catch block?

Yes, with try-finally

500

How do you sort a List<String> alphabetically?

Collections.sort(list)

500

What is a functional interface?

An interface with only one abstract method (e.g., Runnable)

M
e
n
u