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