Computer Applications

Give the output of the following

switch (x)
{
case 'M' :
    System.out.print ("Microsoft Teams");
    break; 
case 'G':
    System.out.print ("Google Meet"); 
default:
    System.out.print("Any Software"); 
    break;
case 'W': 
    System.out.print("Web Ex"); 
    break;
}

when x = 'g'

  1. Google Meet
  2. Any Software
  3. Google Meet
    Any Software
  4. Web Ex

Java Conditional Stmts

3 Likes

Answer

Any Software

Reason — Java is a case sensitive language and thus 'G' and 'g' are treated as two different characters. Since the value of x does not match with any case, the default case will be executed. Thus, "Any Software" will be printed.

Answered By

1 Like


Related Questions