Java Fundamentals
Object-Oriented Concepts
Multithreading & Concurrency
100

What keyword is used to create a constant variable in java?

What is final?

100

What principle is demonstrated by the ability of a subclass to provide a specific implementation of a method defined in a superclass?

Polymorphism

100

Which interface do you implement to define a task for a thread?

Runnable

200

What will be the output?

System.out.println("Result: " + 2 + 3);

Result: 23

200

What keyword prevents multiple threads from accessing a block of code simultaneously?

synchronized

300

What is the difference between == and .equals() when comparing strings?

== checks reference equality,

.equals() checks value equality

300

What will happen if you call 

    Thread.sleep(1000); 

inside a synchronized method?

The thread sleeps but keeps holding the lock, blocking others

400

Why does this code produce a compilation error?

int x = null;

int is a primitive type and cannot be assigned null

400

What is the main advantage of using ExecutorService over manually creating threads?

It manages thread pools, reusing threads and controlling lifecycle efficiently

500

What is the output of this code?

int[] arr = {1, 2, 3};

System.out.println(arr[3]);

ArrayIndexOutOfBoundsException