Which of the following are keywords or reserved words in Java?

  1. if

  2. then

  3. goto

  4. while


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) if - This option is a keyword in Java. The "if" keyword is used to specify a condition in an if statement.

Option B) then - This option is incorrect. "Then" is not a keyword or reserved word in Java.

Option C) goto - This option is incorrect. "Goto" is not a keyword or reserved word in Java.

Option D) while - This option is a keyword in Java. The "while" keyword is used to create a while loop, which repeatedly executes a block of code as long as a given condition is true.

The correct answer is B. "Then" is not a keyword or reserved word in Java.

Find more quizzes: