Consider the following code segment.
String a = "";
a += "0";
if (a == "0") {
System.out.println("a is 0!");
} else if (a == "1") {
System.out.println("a is 1!");
} else if (a == "a") {
System.out.println("a is a!");
} else {
System.out.println("a is something else!");
}
Which of the following statements about the code segment is true?
a. It produced "a is 0!" as output incorrect
b. It produced "a is 1!" as output
c. It produced "a is a!" as output
d. It produced "a is something else!" as output
e. It results in an error because the == operation can not be used with Strings
Answers
Answered by
1
Answer:
well, the output would be a is 0.
so, in the question (a) part is written wrong cuz that will be the answer
Similar questions
Computer Science,
4 months ago
Social Sciences,
4 months ago
Math,
4 months ago
English,
8 months ago
English,
8 months ago
Math,
11 months ago
Biology,
11 months ago
Math,
11 months ago