Sunday, February 20, 2011

variables questions on java with explanation


Questions on variables in java with answers


(1)



public class Test {

public static void main(String[] args) {

int a=5;

{

Integer b=10;

}

int c=a+b;

System.out.println(c);

}

}



What will output when you compile and run the above code?



(a)15

(b)5

(c)Compiler error

(d) Run time error











Answer: (c)



No comments:

Post a Comment