Which keyword is used to explicitly throw an exception in Java?
catch
finally
try
throw
Why would you create a custom exception class in Java?
To avoid handling exceptions altogether.
To improve the performance of exception handling.
To represent specific exception scenarios relevant to your application.
To modify the behavior of existing Java exception classes.
What is a potential risk of poorly implemented recursion?
Increased memory usage.
Slower execution speed.
All of the above.
StackOverflowError.
What is the primary purpose of a constructor in Java?
To define methods
To control access to class members
To initialize object attributes
To declare variables
What is recursion in the context of Java methods?
Calling a method from a different class
Overloading a method with different parameters
A method calling itself within its own definition
Returning multiple values from a method
Which access modifier allows a subclass in a different package to access a member of its superclass?
private
public
protected
default
What is the time complexity of the get() method for an ArrayList?
get()
O(1)
O(n)
O(n log n)
O(log n)
Which keyword is used to define a block of code that might throw an exception?
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 the default value of an element in an array of type double?
double
0
null
0.0
undefined