What keyword is used to create a constant variable in java?
What is final?
What principle is demonstrated by the ability of a subclass to provide a specific implementation of a method defined in a superclass?
Polymorphism
Which interface do you implement to define a task for a thread?
Runnable
What will be the output?
System.out.println("Result: " + 2 + 3);
Result: 23
What keyword prevents multiple threads from accessing a block of code simultaneously?
synchronized
What is the difference between == and .equals() when comparing strings?
== checks reference equality,
.equals() checks value equality
What will happen if you call
Thread.sleep(1000);
inside a synchronized method?
The thread sleeps but keeps holding the lock, blocking others
Why does this code produce a compilation error?
int x = null;
int is a primitive type and cannot be assigned null
What is the main advantage of using ExecutorService over manually creating threads?
It manages thread pools, reusing threads and controlling lifecycle efficiently
What is the output of this code?
int[] arr = {1, 2, 3};
System.out.println(arr[3]);
ArrayIndexOutOfBoundsException