Explore our extensive collection of questions and answers to enhance your learning experience and prepare for exams effectively
The Comparable interface provides the compareTo() method for natural ordering of objects.
Assert is used to check conditions that should be true, throwing an AssertionError if false.
The contains() method returns true if the string contains the specified substring.
‘Z’ (90) – ‘A’ (65) = 25, calculated as the difference in ASCII values.
The super keyword is used to call a constructor or method from the superclass.
Both ArrayList list = new ArrayList(); and List list = new ArrayList(); are valid declarations.
ArrayList provides O(1) time complexity for accessing elements by index due to its array-based structure.
The remove() method removes an element at a specified index or an object from an ArrayList.
Synchronized ensures thread safety by allowing only one thread to execute the block or method at a time.
Math.round() rounds a number to the nearest integer, so 3.7 rounds to 4.