Computer Science, asked by hypersonic1234321, 11 hours ago

predict the output in java
int ch =3;
{
case 1:System.out.println("red");
case 2:System.out.println("yellow");
case 3:System.out.println("black");
}​

Answers

Answered by samarthkrv
0

Answer:

the output is black

Explanation:

A better form is -

import java.util.*;

class Brainly

{

public static void main(String[] args)

{

int ch = 3;

 switch(ch)

 {

  case 1:

  {

  System.out.println("red");

  break;

  }

  case 2:

  {

  System.out.println("yellow");

  break;

  }

  case 3:

  {

  System.out.println("black");

  break;

  }

 }

}

}

Similar questions