Java.lang Class

Q1: What will be the output of the program?
String x = new String('xyz');
String y = 'abc';
x = x + y;
How many String objects have been created?

A 2

B 3

C 4

D 5

ANS:A - 2

Line 1 creates two, one referred to by x and the lost String 'xyz'. Line 2 creates one (for a total of three). Line 3 creates one more (for a total of four), the concatenated String referred to by x with a value of 'xyzabc'.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.