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