Java Online Screening TestBy Collab Team Contributor / February 8, 2025 Java Online Screening Test 1 / 20 Which of the following is true about Java garbage collection? It automatically removes unreachable objects. It can be explicitly controlled. Developers must manually call the garbage collector. It guarantees that all unused objects are removed. 2 / 20 What is the default capacity of an ArrayList when initialized with an empty constructor? 8 10 5 16 3 / 20 Which method of ConcurrentHashMap is atomic? remove() computeIfAbsent() put() get() 4 / 20 What does the filter() method in Java Streams do? Modifies each element in the stream Filters elements based on a predicate Sorts elements in the stream Converts elements to another type 5 / 20 Which collection class allows concurrent modification by multiple threads? ArrayList LinkedList CopyOnWriteArrayList HashSet 6 / 20 Which Java feature ensures that an object is not modified once it is created? Immutability Polymorphism Encapsulation Serialization 7 / 20 Which Java class is designed for thread-safe counter updates? AtomicInteger ThreadLocal Integer Semaphore 8 / 20 Which interface provides a method to retrieve elements sequentially from a collection? HashMap Comparator Iterable Enumeration 9 / 20 What will happen if a thread calls the wait() method inside a synchronized block? It will release the lock and enter the waiting state. It will go to the ready state. It will continue execution. It will throw an exception. 10 / 20 Which method is used to schedule a task for execution in ScheduledExecutorService? execute() run() start() schedule() 11 / 20 What will happen if join() is called on a thread? The program exits. The calling thread waits for the joined thread to finish. Both threads terminate immediately. The joined thread waits for the calling thread. 12 / 20 Which stream operation is terminal? collect() map() filter() flatMap() 13 / 20 Which functional interface represents an operation that takes one argument and returns a result? Consumer Supplier Function Runnable 14 / 20 Which functional interface does the forEach() method accept? Consumer Supplier Function Predicate 15 / 20 Which of the following is not a valid access modifier in Java? public private protected internal 16 / 20 Which Java collection class does not allow duplicate keys but allows duplicate values? HashSet HashMap LinkedList TreeMap 17 / 20 Which class in Java is immutable by design? HashMap String ArrayList StringBuilder 18 / 20 Which lock mechanism in Java provides explicit control over locking? AtomicBoolean synchronized block ReentrantLock volatile keyword 19 / 20 What will Optional.ofNullable(null).orElse("Default") return? "Default" null Compilation error NoSuchElementException d 20 / 20 Which of the following is true about volatile in Java? It ensures visibility but not atomicity. It locks the variable. It ensures atomicity. It replaces synchronized blocks. Your score isThe average score is 56% 0% Restart quiz