MCQ Single Best Answer Moderate

QWhich of the following is a valid Java statement?

ID: #24857 Control flow in programming 5 views
Question Info
#24857Q ID
ModerateDifficulty
Control flow in programmingTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A int a = 5;
  • B if int a
  • C int switch b;
  • D int 5 = a;
Correct Answer: Option A

Explanation

A) int a = 5;

The statement int a = 5; is a correct and valid Java statement because it properly declares and initializes a variable.

Breakdown:

  • int → Data type
  • a → Variable name
  • = 5 → Assigns the value 5 to the variable
  • ; → Statement terminator in Java

Why the other options are incorrect:

  • if int a
    This is incomplete and does not follow proper Java syntax.
  • int switch b;
    The word switch is a reserved keyword in Java and cannot be used as a variable name.
  • int 5 = a;
    Variable names cannot start with numbers in Java.
No Previous Next Question

Share This Question

Challenge a friend or share with your study group.