The switch….case Practical

Advertisements
Advertisements
Advertisements3
Advertisements4
Advertisements6
Advertisements66

1.What is the output of the Java program below?

String animal = "GOAT";
switch(animal)
{
  break: System.out.println("DOMESTIC");
}

Ans. Compile error.

2. What is the output of Java program with SWITCH?

int num=20;
switch(num)
{
case 10: System.out.println("TEN"); break;
case 20: System.out.println("TWENTY"); break;
case 30: System.out.println("THIRTY");
}

Ans. TWENTY

 

Author: Lakshmi Prasanna Ponnala

Completed M.Tech in Digital Electronics and Communication Systems.

Leave a Reply

error: Content is protected !!

Discover more from ece4uplp

Subscribe now to keep reading and get access to the full archive.

Continue reading