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
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
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 typea→ 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 wordswitchis a reserved keyword in Java and cannot be used as a variable name. -
❌
int 5 = a;
Variable names cannot start with numbers in Java.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic