Ask Question
30 July, 20:29

In the given switch statement, what will be displayed if the value of var is 3? switch (var) { case 1: System. out. println ("Apple"); break; case 2: System. out. println ("Banana"); break; case 3: System. out. println ("Peach"); case 4: System. out. println ("Pear"); case 5: System. out. println ("Pineapple"); break; default : System. out. println ("Cantaloupe"); break; } A. Peach Peach B. Pear Peach C. Pear Pineapple D. None of the above.

+4
Answers (1)
  1. 30 July, 21:30
    0
    The output of the given program is

    Peach Pear Pineapple.

    Explanation:

    since the value of var is so control will move to the case 3 directly and executed the statement inside the case 3 so it will print "Peach" in window after that their is no break statement in the case 3 the control moves the case 4 and executed the statement inside the case 4 so it will print "Pear" in window again there is no break statement in the case 4 the control moves the case 5 and executed the statement inside the case 5 so it will print "Pineapple". Finally, the break statement is reached the execution of the program is stopped.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “In the given switch statement, what will be displayed if the value of var is 3? switch (var) { case 1: System. out. println ("Apple"); ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers