Computer Applications
Which of the following is true about the default label in a switch statement?
Java Conditional Stmts
2 Likes
Answer
It executes if no matching case label is found.
Reason — The default label in a switch statement is used as a fallback option. If none of the case labels match the switch expression, the default block executes.
- Including a
defaultlabel is optional in aswitchstatement. - It can appear anywhere within the
switchblock. - The
defaultlabel can appear only once, but its position within theswitchblock is flexible (not restricted to the top).
Answered By
2 Likes
Related Questions
An air-conditioned bus charges fare from the passengers based on the distance travelled as per the tariff given below:
Distance Travelled Fare Up to 10 km Fixed charge ₹80 11 km to 20 km ₹6/km 21 km to 30 km ₹5/km 31 km and above ₹4/km Design a program to input distance travelled by the passenger. Calculate and display the fare to be paid.
The statement that brings the control back to the calling method is:
- break
- System.exit(0)
- continue
- return
A triangle is said to be an 'Equable Triangle', if the area of the triangle is equal to its perimeter. Write a program to enter three sides of a triangle. Check and print whether the triangle is equable or not.
For example, a right angled triangle with sides 5, 12 and 13 has its area and perimeter both equal to 30.