Single Choice Moderate

QWhich returns 'Adult' if age>=18 else 'Minor'?

ID: #25982 MCQ Quiz - Class 8 - Decision Control Structure 2 views
Question Info
#25982Q ID
ModerateDifficulty
MCQ Quiz - Class 8 - Decision Control StructureTopic

Choose the Best Option

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

  • A age>=18 ? 'Adult' : 'Minor'
  • B age>=18 : 'Adult' ? 'Minor'
  • C age?18:Adult
  • D None
Correct Answer

Explanation

Correct Answer Explanation:

The correct ternary syntax: condition ? valueIfTrue : valueIfFalse — cleanly gives 'Adult' when age>=18, otherwise 'Minor'.

Why the other options are incorrect:

  • Option B: The ? and : are in wrong order.
  • Option C: Missing the comparison operator.
  • Option D: The correct syntax exists.

Share This Question

Challenge a friend or share with your study group.