What will the code fragment below print Type your answer in

What will the code fragment below print? Type your answer in the box below. char letter = \'c\'; switch(letter) { case \'a\': System.out.println(\"A\"); break; case \'b\': System.out.println(\"B\"); break; default: System.out.println(\"default\"); }

Solution

Answer:

defalut

here is how.. explainted in program... explaination in comments.....

public
class HelloWorld {

public
static void main(String[] args)
{
char letter = \'c\';
switch (letter) { // matches the letter \'c\'
case \'a\':
System.out.println(\"A\");
break;
case \'b\':
System.out.println(\"B\");
break;
default: // no condition matches with letter .. so default code executes
System.out.println(\"default\"); // prints default
}
}
}

Output:

default

What will the code fragment below print? Type your answer in the box below. char letter = \'c\'; switch(letter) { case \'a\': System.out.println(\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site