What is the value of x after this line: double x = 5 / 2;?
What is 2.0?
How many times will the following loop execute? for (int i = 0; i < 10; i += 2)
What is 5 times (i = 0, 2, 4, 6, 8).?
What keyword is used in a subclass header to show it inherits from a superclass?
What is extends?
What is the index of the very last element in an array named arr?
What is arr.length - 1 ?
What is the "base case" in a recursive method?
What is The condition that stops the recursion from continuing ?
Which String method returns a new string with the same characters but in all capital letters?
What is .toUpperCase()?
Apply De Morgan’s Law to rewrite this boolean expression: !(a && b)
What is !a || !b ?
True or False: A private variable in a superclass can be directly accessed by name in a subclass.
What is False ?
Which method is used to find the number of elements in an ArrayList?
What is .size() ?
In a 2D array declared as int[][] mat = new int[3][5];, how many total elements are there?
What is 15?
What is the range of possible values for the expression: (int)(Math.random() * 10) + 5?
What is Any integer from 5 to 14 inclusive.?
What is the result of 17 % 5?
What is 2?
What is the purpose of the super() call in a constructor?
To call the constructor of the parent/superclass.
What error is thrown if you try to access list.get(5) on an ArrayList with only 3 elements?
What is IndexOutOfBoundsException ?
Which search algorithm requires the data to be sorted before it can be used?
Binary Search.
Given String s = "Computer";, what is returned by s.substring(2, 5)?
What is "mpu" (Indices 2, 3, and 4; index 5 is exclusive).?
In a while loop, what happens if the condition is initially false?
The body of the loop is never executed.
Define "Method Overloading."
When two or more methods in the same class have the same name but different parameter lists.
When using an enhanced for-loop (for-each) to traverse an ArrayList, what is a major restriction regarding the list's structure?
What is ConcurrentModificationException?
What is the output of f(3)?
public int f(int n) {
if (n <= 0) return 1;
return n + f(n - 1);
}
what is 7 ? (3 + 2 + 1 + 1)
Explain the difference between == and .equals() when comparing two String objects.
What is == compares the memory addresses (references), while .equals() compares the actual literal sequence of characters.?
What is the output of the following code snippet?
for (int i = 1; i <= 3; i++) {
for (int j = i; j > 0; j--) {
System.out.print(j);
}
}
What is 121321?
If class Dog extends Animal, and you write Animal myPet = new Dog();, which class determines which version of an overridden method is called at runtime?
The Dog class (Dynamic Method Selection).
Write the code to remove the third element from an ArrayList of Strings called names
What is names.remove(2);
What is the Worst Case Big-O complexity of a Selection Sort?
$O(n^2)$