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

3/7

Page

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

What is the result of the following code in Java? `System.out.println(5 / 0);`

Select an option to see the answer and solution.

In Java, which data type is used to represent true or false values?

Select an option to see the answer and solution.

What does the `break` statement do when used in a `switch` statement in Java?

Select an option to see the answer and solution.

Which Java keyword is used to explicitly specify that a variable cannot be changed after it is assigned a value?

Select an option to see the answer and solution.

What is the purpose of the `String.format()` method in Java?

Select an option to see the answer and solution.

Which Java keyword is used to define a constant interface?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

In Java, which collection class does not allow duplicate elements and is typically implemented as a binary tree?

Select an option to see the answer and solution.

What is the result of the following code in Java? `System.out.println(10 > 5 ? "true" : "false");`

Select an option to see the answer and solution.

In Java, which exception is thrown when an attempt is made to access an array element with an index that is negative or greater than or equal to the array size?

Select an option to see the answer and solution.

Which Java keyword is used to define a subclass that inherits from another class?

Select an option to see the answer and solution.

What does the `super` keyword refer to in Java?

Select an option to see the answer and solution.

In Java, what is the purpose of the `transient` keyword when applied to an instance variable?

Select an option to see the answer and solution.

What is the output of the following code snippet in Java? `System.out.println(Math.pow(2, 3));`

Select an option to see the answer and solution.

Which Java operator is used to perform a bitwise XOR operation between two integers?

Select an option to see the answer and solution.

What is the purpose of the `instanceof` operator in Java?

Select an option to see the answer and solution.

In Java, which exception is thrown when an object is accessed before it has been initialized?

Select an option to see the answer and solution.

Which Java class is used to represent an ordered collection of elements?

Select an option to see the answer and solution.

What is the purpose of the `synchronized` keyword in Java?

Select an option to see the answer and solution.

In Java, what does the `this` keyword refer to?

Select an option to see the answer and solution.