Which loop in Java is guaranteed to execute at least once, even if the condition is initially false?
enhanced for loop
while loop
for loop
do-while loop
What does it mean for a method to have a 'void' return type?
The method throws an exception.
The method is not yet implemented.
The method doesn't return any value.
The method returns an empty string.
What is the time complexity of the get() method for an ArrayList?
get()
O(n log n)
O(log n)
O(n)
O(1)
Which operator is used for string concatenation in Java?
/
What is the parent class of all exception classes in Java?
Exception
RuntimeException
Error
Throwable
Which keyword is used to define a block of code that might throw an exception?
throw
catch
finally
try
What is essential to prevent infinite recursion in a Java method?
A return statement in all code paths
A conditional statement that terminates the recursion
Using a different method name for each recursive call
A loop within the recursive method
What is the base class for all checked exceptions in Java?
What is the fundamental difference between Java and JavaScript?
Java is a scripting language, while JavaScript is a compiled language.
Java is a statically-typed language, while JavaScript is dynamically-typed.
They are essentially the same; the names are interchangeable.
Java is primarily used for client-side web development, while JavaScript is used for server-side applications.
Which keyword is used to explicitly throw an exception in Java?