Sunday 20 February 2011

Character literals questions on java and answer with solution

Objective types questions and answers of character literals in java


(1)



public class Literal {

    public static void main(String[] args) {

         char b ='\n';

         int a=(int)b;

         System.out.println(a);

    }

}



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



(a)10

(b)11

(c)12

(d) Compiler error









Answer: (a)





(2)



public class Literal {

No comments:

Post a Comment