Primitive Types
Which for-loop declaration correctly traverses an integer array named 'numbers' from its end to its beginning?
for(int i = numbers.length - 1; i >=0; i--)
for(inti=numbers.lengh-1;i< numbers .length;i-- )
for(int i=0 ;i <numbers.length;i++ )
for(int i = numbers.length; i >0; i++)
What should replace 'XXXX' in the following snippet to correctly handle exceptions that may arise from file operations?
java
try (FileReader fr = new FileReader("file.txt")) {
// read file
} catch (XXXX e) {
System.out.println("An error occurred.");
}
InterruptedIOException
EOFException
FileNotFoundException
IOException
When implementing an interface 'X' containing a default method 'foo', what happens if both superclass 'Y' and subclass 'Z' do not override 'foo'?
Subclass Z automatically creates an abstract version of foo.
Subclass Z inherits the default implementation from interface X.
Compilation fails due to lack of implementation in subclass Z.
An abstract method must be provided in superclass Y for Z to implement.
Given a double variable distance = 8.5
, which expression changes its value to half of its original?
distance /= 2;
distance %= 2;
distance *= .5;
distance -= 2;
What is printed as a result of executing System.out.println(9 / "3".length()); ?
It prints "0".
It prints "3".
It causes a compile error.
It prints "9".
If we want to insert a new value into a sorted array while maintaining its order, what typical algorithm must be used?
Quick sort algorithm applied after inserting the new element at the end of the array.
Linear search followed by an arbitrary swap or replacement action.
Sorting algorithm with insertion technique.
Binary search algorithm without modifications to the array.
Which algorithmic approach would likely be most efficient for finding an item in a balanced binary search tree?
Bubble sort then linear search.
Linear search.
Selection sort then binary search.
Binary search.

How are we doing?
Give us your feedback and let us know how we can improve
What is the result of 'value--' if value is initially 8?
9
8
7
6
What will be the output of the following code if the integer value 0 is passed to it?
java
try {
System.out.println(10 / a);
} catch (ArithmeticException e) {
System.out.println("Error");
}
An exception is thrown but not caught
10
undefined
Error
When comparing recursion and iteration for solving problems, what kind of scenarios might favor recursive solutions over iterative ones for equal efficiency?
Simple counting problems lacking divide-and-conquer characteristics.
Scenarios requiring optimization using greedy methods.
Problems exhibiting self-similarity like fractals or recursive patterns.
Highly sequential tasks without natural breaking points into smaller sub-tasks.