What will be the output of the following code?int p = 3,ch = 2;switch(ch){case 1: System. Out. Println("The square is: " + p*p);break;case 2: System. Out. Println("The cube is: " + p*p*p);break;default: System. Out. Println("No Output Value");}
“The cube is: 27” or p^3 The switch function uses the ch int and identifies a matching case. Because ch is 2 We use case 2 Thus the following line at the top is printed. Then automatically breaks the function, so we don’t continue.