93. What will happen when you attempt to compile and run this code?
1 u! T+ N* @' o! s5 b" d1 dpublic class MySwitch{1 K, f1 v1 b0 |& s) z( Y
public static void main(String argv[]) {2 S, U$ r3 v ?. L$ \5 P
MySwitch ms = new MySwitch(;% R% N# s1 J+ ~' u0 {- r
ms.amethod();3 x# _; O1 c, B. } s. J# V
}
. n( @- E4 N1 E* F& Z$ W6 ^public void amethod() {
# p+ H7 L1 b0 p/ xchar k=10;
! H5 F3 O9 h, g: I- l% G7 c- q3 ^switch(k){
# r$ i# z' [2 O& i2 Rdefault:6 ~$ ~5 M6 d1 f4 o
System.out.println("This is the default output");: k, c! P% Z& ~. R+ f8 S; a
break;/ B( q) G* W7 W7 O m! q
case 10:% \& }2 z* w2 G6 Z& i$ f
System.out.println("ten");
& f; b8 F* O% Z" l0 Dbreak;
9 x' l5 ^- r4 Z( Ncase 20:
0 s; N i! E0 R; k% aSystem.out.println("twenty");8 T8 @9 m9 V; O& d3 |7 L
break;1 K% m' c9 o! X
}
O/ y& A* P! d1 ~5 C}
2 A1 @; W( V, \9 G} v5 ]0 U, j. y4 b3 k
A. None of these options
! {2 ^. ]+ }" j0 h1 LB. Compile time error target of switch must be an integral type- `4 y" T, i6 C4 D% \9 ]6 m" _
C. Compile and run with output "This is the default output"
2 b/ d/ b) I. V9 c( J0 t& WD. Compile and run with output "ten"# n1 G0 T/ a2 W/ W" O9 X3 t
D.+ D0 O* A; f+ N) \9 v
94. What will happen when you attempt to compile and run the following code?) V* K! s9 e9 L8 g9 p
public class MySwitch{8 D$ F; h/ i3 Q1 [# P
public static void main(String argv[]) {
8 K. G) j) H8 z0 M$ `+ _MySwitch ms = new MySwitch();$ u- _9 F1 F7 @0 {$ j. G; g/ e
ms.amethod();
# z$ g9 [5 s- U}. T! ~+ n7 e1 s& l6 m7 s" e
public void amethod() {. o6 j0 D2 q4 E0 S
int k=10;3 ]# ~+ |: K+ Z5 Y
switch (k){' H- u1 `0 h! T& m D. k& v7 `
default: //Put the default at the bottom, not here
* c" N! G; \' ~2 q$ y" sSystem.out.println("This is the default output");* C- d9 Z, V/ z8 k" a7 Q! U! t
break;; D% m* Y* w3 F6 X& A. y
case 10:5 f3 @% s# z0 ?" g( v8 c) b
System.out.println("ten");
/ p/ }7 {$ r- B/ D7 F0 v& ocase 20:/ i. s3 r( d7 t* r
System.out.println("twenty");. ]* O% H4 Z# r2 K7 K6 U
break;6 i/ p3 ^" K1 j' o+ A
}' s) h) K, ^4 V
}
]0 }% r$ Q7 k9 }. }" C) A: Z}
6 M, H' L. I9 p8 _" r# bA. None of these options
$ c; n+ ] B. {B. Compile time error target of switch must be an integral type
. O# E6 ^9 v% a# y9 H5 xC. Compile and run with output "This is the default output; b- H* j9 [. p; x7 ]+ z
D. Compile and run with output "ten"& B3 k5 q. n5 U+ F( \' \
A. |