Sunday, February 20, 2011

static keyword interview questions in java


Interview questions of static keyword in java and answers

(1)



class StaticDemo {

static int a=0;

int b=++a;

static int c=++a;



public static void main(String[] args){

System.out.print(c);

}

}



What will be output of above program?



(a)0

(b)1

(c)2

(d)Compiler error













Answer: (b)



(2)



class StaticDemo {

int a=0;

No comments:

Post a Comment