[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

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);
}
}

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 :: TCS NQT

Post Your Answer Here:     

Reply    
Rate This: +0 -1
    Report


Report Error

Please Login First Click Here