What would be the result of running the following code when noOfBedrooms has the value 3?
// noOfBedrooms is assumed to be non-negative.
switch (noOfBedrooms) {
case 0:
System.out.println("I hope you have a car!");
break;
case 1:
System.out.println("Nice and cosy.");
break;
case 2: case 3: case 4:
System.out.println("Room for a family...");
break;
case 5:
System.out.println("You should get a lodger!");
break;
default:
System.out.println("I hope you have a car!");
break;
} // switchss
Consider the following fragment of code.
int count = Integer.parseInt(args[0]);
switch (count) {
case 5: System.out.println("Got 5");
case 4: System.out.println("Got 4");
case 3: System.out.println("Got 3");
case 2: System.out.println("Got 2");
case 1: System.out.println("Got 1");
case 0: System.out.println("Got 0");
} // switchWhy are there five lines output of the first command line argument is 4?
ss