0
What is the output and why???
class A { public static void main(String args[]) { int x; x = 5; { int y = 6; System.out.print(x +""+y); } System.out.println(x +""+y); } }
1 Réponse
+ 4
An error will be thrown, bcz of scope of variables, scope of variable is valid only in a block (braces), you declared y in a block,. So it's scope/validation will only be in this block, you can not use this y outside of that block, so it will throw an error.