JAVA Programming :: Basic Concepts - Discussion
Home > JAVA Programming > Basic Concepts > MCQs Questions Discussion
46 / 64
What is the result of compiling and running the following program.
public class test {
public static void main(String args[]) {
String str1="abc";
String str2="def";
String str3=str1.concat(str2);
str1.concat(str2);
System.out.println(str1);
}
}
public class test {
public static void main(String args[]) {
String str1="abc";
String str2="def";
String str3=str1.concat(str2);
str1.concat(str2);
System.out.println(str1);
}
}
Aabc
Bdef
Cabcabc
Dabcdef
Edefabc
Answer: Option (Login/Signup)
Show Explanation
Don't get confused by line no. 6 i.e, str1.concat(str2);
We are concatinating str1 with str2, but the resultant string having the content as "abcdef" has no reference. It's definitely not that str1 refers to "abcdef"
Asked In ::
STEP-BY-STEP
The output is abc, because the content of str1 is "abc".
Don't get confused by line no. 6 i.e, str1.concat(str2);
We are concatinating str1 with str2, but the resultant string having the content as "abcdef" has no reference. It's definitely not that str1 refers to "abcdef"
Read Full Answer
Report Error
Please Login First Click Here