Showing posts with label compile. Show all posts
Showing posts with label compile. Show all posts

Saturday, 11 February 2012

What will be the result of an attempt to compile and run the following program?

class Test
{

public static void main(String args[])
{


String s1 = "abc";
String s2 = "abc";
s1 += "xyz";
s2.concat("pqr");
s1.toUpperCase();
System.out.println(s1 + s2);


}


}

Choices:

  • A. "abcxyzabc"

  • B. "abcxyzabcpqr"

  • C. "ABCXYZabcpqr"

  • D. "ABCXYZabc"

  • E. Code does not compile


Correct choice:

  •  A


Explanation: