Sunday 20 February 2011

enum example in java


Questions on enum data type in java and answers

(1)



enum Barcode{

    a,b,c,d,e;

}



public class EnumTest {

    public static void main(String[] args) {

         System.out.println(Barcode.b);

    }

}



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



(a)1

(b)2

(c)b

(d)Compiler error













Answer:(c)



(2)



enum Barcode{

    a,b,c,d,e;

}



public

No comments:

Post a Comment