hi priya,
Before going to u r question fist make one thing clear
in u r mind in
java there is no concept call garbage value
for variabels hence all variable r to be initilised
now in u question u r conceriding only one case i.e value of
i=2; in this case while execution control will go directly to
case 2 and will try to println value of j which is which is not
initilized. because it never went to case 1 to execute int j=10
so we r trying to print garbage value of j which is not posible
now. U Will Say But Why Cant i define int j=30 in case 2
this is because it has define at case 1 and compiler can detect
it while compiling casue it goes thow all case
..hope u get it
...praful
SCJP