Vidyalelo
Java Programming · all questions

Miscellaneous Java
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

121

Questions

2/7

Page

Pick an option on a question to see the right answer and solution.

What is the output of the following code in Java? `System.out.println("Hello" + 1 + 2 + 3);`

Select an option to see the answer and solution.

In Java, what is the purpose of the `compareTo` method in the Comparable interface?

Select an option to see the answer and solution.

Which data structure in Java is based on the Last-In-First-Out (LIFO) principle?

Select an option to see the answer and solution.

What is the default value of a local variable in Java if it is not explicitly initialized?

Select an option to see the answer and solution.

Which Java operator is used to perform bitwise AND between two integers?

Select an option to see the answer and solution.

What does the `finally` block in a Java `try-catch-finally` construct do?

Select an option to see the answer and solution.

In Java, which collection is typically implemented as a dynamic array that can grow or shrink in size?

Select an option to see the answer and solution.

What is the purpose of the `@Override` annotation in Java?

Select an option to see the answer and solution.

In Java, what is the role of the `System.arraycopy` method?

Select an option to see the answer and solution.

Which Java operator is used to perform a logical NOT operation?

Select an option to see the answer and solution.

Which Java keyword is used to create a new instance of a class?

Select an option to see the answer and solution.

In Java, what is the purpose of the `NullPointerException`?

Select an option to see the answer and solution.

What is the purpose of the `try-with-resources` statement in Java?

Select an option to see the answer and solution.

Which Java operator is used for short-circuit logical OR?

Select an option to see the answer and solution.

In Java, what does the `System.exit(0);` statement do?

Select an option to see the answer and solution.

What is the output of the following code snippet in Java? `System.out.println("Java".substring(0, 2));`

Select an option to see the answer and solution.

Which Java exception is thrown when an array index is out of bounds?

Select an option to see the answer and solution.

In Java, which data type represents a sequence of characters and is enclosed in double quotes?

Select an option to see the answer and solution.

What is the primary purpose of the `finally` block in a Java exception handling structure?

Select an option to see the answer and solution.

Which Java keyword is used to declare a class method that can be called without creating an instance of the class?

Select an option to see the answer and solution.