Which method is used to remove an element at a specific index from an ArrayList?
remove()
extract()
delete()
discard()
What is the default value of an element in an array of type double?
double
null
0.0
0
undefined
What is the parent class of all exception classes in Java?
Error
Throwable
RuntimeException
Exception
What are method parameters used for?
To control the method's access level
To pass data into a method
To declare variables within a method
To define the method's return type
Which component of the Java Development Kit (JDK) is responsible for converting Java source code (.java files) into bytecode (.class files)?
Java Runtime Environment (JRE)
Java Compiler (javac)
Java Virtual Machine (JVM)
Integrated Development Environment (IDE)
Which of the following is NOT a valid way to declare an array in Java?
int []arr;
int arr[];
int arr[] = new int[5];
int[] arr;
Which loop in Java is guaranteed to execute at least once, even if the condition is initially false?
for loop
while loop
do-while loop
enhanced for loop
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));
IndexOutOfBoundsException
apple
banana
Which keyword is used to define a method in Java?
method
void
function
define
What will the following Java code snippet print to the console?
for (int i = 1; i <= 3; i++) { System.out.print(i + " "); }
3 2 1
1 2 3
The code will result in a compilation error.
123