What will be output?
String S1 = "S1 ="+ "123"+"456";
String S2 = "S2 ="+(123+456);
String S1 = "S1 ="+ "123"+"456";
String S2 = "S2 ="+(123+456);
A. S1=123456, S2=579
B. S1=123456,S2=123456
C. S1=579,S2=579
D. None of This
Answer: Option A
Solution(By Examveda Team)
If a number is quoted in "" then it becomes a string, not a number any more.
Join The Discussion
Comments ( 3 )
Related Questions on Strings
In Java, which class is used to represent a sequence of characters as a string?
A. String
B. StringBuilder
C. StringSequence
D. StringArray
What is the correct way to create a new empty String object in Java?
A. String emptyString = "";
B. String emptyString = new String();
C. String emptyString = " ";
D. String emptyString = null;
E. Both A and B
Which of the following methods is used to compare two strings for equality in Java?
A. equals()
B. compareTo()
C. equalsIgnoreCase()
D. compare()
None of these,
Coz the output will be
S1 =123456, S2 =579
S1 with space and = after number
Same for s2
What would be behaviour if the constructor has a return type?
Select one:
a. Compilation and runs successfully
b. Compilation error
c. Runtime error
d. Only String return type is allowed
Mistakes have been made...