मराठी

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 - Computer Applications

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);
  1. The expression (age > 10) checks if the user's age is greater than 10.
  2. The ? operator acts as the if. If the condition is true, "Eligible" is assigned. The : acts as the else. If false, "Not eligible" is assigned.
  3. The resulting message is stored in the String variable idStatus as specifically requested in the question.
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2025-2026 (March) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×