Which collection would you use if you need to maintain a sorted order of elements and also need O(log n) insertion/deletion time complexity?
Q.142Medium
Which of the following statements is true about PriorityQueue?
Q.143Medium
What is the time complexity of get() operation on a LinkedHashMap with n elements?
Q.144Medium
Which collection interface should be used if you need both key-value pairing and need to iterate in the order of keys' natural ordering?
Q.145Medium
What will be printed? Queue<Integer> queue = new LinkedList<>(); queue.add(10); queue.add(20); queue.add(30); System.out.println(queue.poll()); System.out.println(queue.peek());
Advertisement
Q.146Medium
What is the difference between Thread.sleep() and Thread.yield()?
Q.147Medium
What is the purpose of the synchronized keyword in Java multithreading?
Q.148Medium
Which of the following is NOT a thread state in Java?
Q.149Medium
What will be the output of calling start() multiple times on the same thread object?
Q.150Medium
What is a race condition in multithreading?
Q.151Medium
Consider a synchronized method. Can multiple threads call it simultaneously on the same object?
Q.152Medium
What is the difference between notify() and notifyAll()?
Q.153Medium
Which class provides thread-safe operations on shared variables in Java?
Q.154Medium
What is a daemon thread in Java?
Q.155Medium
What is a deadlock in multithreading?
Q.156Medium
What is thread pooling and which class is commonly used for it?
Q.157Medium
What will be the output of the following code snippet?
java
class Test extends Thread {
public void run() {
System.out.print("T");
}
}
public class Main {
public static void main(String[] args) {
Test t = new Test();
t.run();
t.start();
}
}
Q.158Medium
Consider a scenario where Thread A acquires Lock1 and tries to acquire Lock2, while Thread B acquires Lock2 and tries to acquire Lock1. What situation arises?
Q.159Medium
Which of the following is a thread-safe collection in Java that can be used without explicit synchronization?
Q.160Medium
What happens if you call interrupt() on a thread that is not in a waiting or sleeping state?