Multiple Choice
Moderate
QWhich of the following is a valid Java statement?
ID: #24857
Control flow in programming
12 views
Question Info
#24857Q ID
ModerateDifficulty
Control flow in programmingTopic
Your Answer
Select All That Apply
Tick every correct option, then press Check Answer.
Correct Answer
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