135.
a.
b.
c.
d.
Answer:
The code above prints the following output:
XYcQRS
First, xValue is
concatenated with the value qrs and so the
value becomes
xyzqrs. Then,
the value is converted to
uppercase and so, the value becomes
XYZQRS. Then, the
character
Z is
replaced with c and so, the value becomes
ZYcQRS.
What are the various ways of assigning a string literal to a
String variable?
Answer:
Following are the various ways of assigning a string literal to a
string variable:
String strValue1 = “String Literal 1”;
String strValue2 = new String(“String
Literal
2”);
String strValue3 = new String(); strValue3 =
“String Literal 3”;
String strValue4 = strValue3;
Approach a creates the String variable strValue1 by assigning a
String literal to it. Approach
b creates the variable strValue2 by
using the String constructor that accepts a String value.
Approach
c creates the variable strValue3 using the default
String constructor and later assigns a value to it. Approach
d
creates the variable strValue4
by assigning another String
variable to it.