What is the default access modifier for a class member in Java if none is specified?
public
protected
default (package-private)
private
Which of the following is a characteristic of unchecked exceptions in Java?
The compiler requires you to handle them explicitly.
They are derived directly from the 'Error' class.
They typically represent recoverable situations.
They are not required to be declared in a method's 'throws' clause.
What is the role of methods in a Java class?
To perform actions or operations on an object's data
To store data associated with an object
To define the blueprint for creating objects
To control the visibility of class members
What is the core principle behind Object-Oriented Programming (OOP) in Java?
Code reusability
Improved memory management
Faster execution speed
Data security
What is the purpose of the 'break' statement in a Java 'switch' statement?
It prints an error message to the console.
It terminates the entire program.
It skips the current iteration of a loop.
It exits the 'switch' block after a matching case is found.
What is the primary purpose of a constructor in Java?
To control access to class members
To initialize object attributes
To declare variables
To define methods
Can a class have multiple constructors?
Yes, as long as they have different parameter lists.
No, a class can only have one constructor.
Yes, but they must have the same parameter list.
Constructors are optional, so a class may or may not have any.
What are fields in a Java class?
Variables that hold the state of an object
Methods that belong to the class
Keywords reserved by the Java language
Constructors used to create objects
What is essential to prevent infinite recursion in a Java method?
A conditional statement that terminates the recursion
Using a different method name for each recursive call
A loop within the recursive method
A return statement in all code paths
What is the result of the expression '10 % 3' in Java?
1
3
3.33
0