What is The output for Following code?



public class Test {
static int x = 5;
static void method1(){
x = 10;
}
static{
x = 15;
}

public static void main(String[] args){

System.out.println(x);
}

}

Answer:

15

No comments:

Post a Comment