Sunday 20 February 2011

java questions for viva


Java questions and answers for viva 

(1)



public class Literal {

    public static void main(String[] args) {

         String str$="world";

         char str_='X';

         String $_=str$+str_;

         System.out.print($_);

            

    }

}



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



(a)world

(b)worldX

(c)world’X’

(d)Compiler error











Answer: (b)

No comments:

Post a Comment