Question: Consider the Java code segment below: int ans = 0 ; int check = 2 ; switch ( check ) { case 1 : ans

Consider the Java code segment below:
int ans =0;
int check =2;
switch (check)
{
case 1: ans++;
case 2: ans++;
case 3: ans++;
default: ans++;
}
What is the value of ans after execution of the code segment?
Selected answer will be automatically saved. For keyboard navigation, press
up/down arrow keys to select an answer.
a ,1
b 2
Consider the Java code segment below: int ans = 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!