Which of the following describes method overloading in Java?
Defining multiple methods with the same name and different parameters
Changing the behavior of an existing method
Calling a method from within itself
Returning different data types from the same method
Can a class have multiple constructors?
No, a class can only have one constructor.
Yes, but they must have the same parameter list.
Yes, as long as they have different parameter lists.
Constructors are optional, so a class may or may not have any.
What is the process of calling a method in Java?
Declaring the method's return type
Defining the method body
Creating an object of the class
Using the method's name followed by parentheses
Which method is used to remove an element at a specific index from an ArrayList?
remove()
extract()
delete()
discard()
Which of the following is NOT a valid way to declare an array in Java?
int arr[] = new int[5];
int []arr;
int[] arr;
int arr[];
If a method in Java is declared 'private,' where can it be accessed?
Only from within the same class
From any class in the application
From any class within the same package
From subclasses, even in different packages
What is the primary purpose of a constructor in Java?
To define methods
To declare variables
To control access to class members
To initialize object attributes
What will be the output of the following code snippet?
ArrayList<String> list = new ArrayList<>(); list.add("apple"); list.add("banana"); System.out.println(list.get(1));
banana
IndexOutOfBoundsException
null
apple
Which of the following is a characteristic of unchecked exceptions in Java?
They are not required to be declared in a method's 'throws' clause.
The compiler requires you to handle them explicitly.
They typically represent recoverable situations.
They are derived directly from the 'Error' class.
Which of the following is NOT a valid access modifier in Java?
private
protected
static
public