What is the purpose of the 'this' keyword within a class?
To create a new instance of the class.
To refer to the current object.
To call a method from the superclass.
To access static members of the class.
What is the base case in a recursive function?
The return statement of the function.
The initial call to the function.
The condition that stops the recursion.
The most complex part of the recursion.
Which keyword is used to explicitly throw an exception in Java?
finally
try
throw
catch
What is the role of parameters in a Java method?
To control the method's visibility.
To declare variables within the method.
To define the method's return type.
To provide input values to the method.
What is the correct syntax to print 'Hello World!' to the console in Java?
echo 'Hello World!';
console.log('Hello World!');
print('Hello World!');
System.out.println('Hello World!');
What is the default access modifier for a class member in Java if none is specified?
private
default (package-private)
public
protected
What is the purpose of the 'break' statement in a Java 'switch' statement?
It terminates the entire program.
It skips the current iteration of a loop.
It prints an error message to the console.
It exits the 'switch' block after a matching case is found.
Which keyword is used to exit a loop prematurely in Java?
continue
exit
return
break
Which of the following is NOT a primitive data type in Java?
boolean
double
String
int
If a method in Java is declared 'private,' where can it be accessed?
From any class within the same package
From subclasses, even in different packages
Only from within the same class
From any class in the application