Advertisements
Advertisements
प्रश्न
Users must be above 10 years to open a self-operated bank account. Write this logic using a ternary operator and store the result (the eligibility message) in a String variable named idStatus and print it.
दीर्घउत्तर
Advertisements
उत्तर
String idStatus = (age > 10) ? "Eligible" : "Not eligible";
System.out.println(idStatus);
- The expression
(age > 10)checks if the user's age is greater than 10. - The
?operator acts as theif. If the condition is true, "Eligible" is assigned. The:acts as theelse. If false, "Not eligible" is assigned. - The resulting message is stored in the String variable
idStatusas specifically requested in the question.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2025-2026 (March) Official Board Paper
