What is the output of the following code?

```
public class Test {
public static void main(String[] args) {
String s1 = "Welcome to Java!";
String s2 = "Welcome to Java!";

if (s1 == s2)
System.out.println("s1 and s2 reference to the same String object");
else
System.out.println("s1 and s2 reference to different String objects");
}
}
```
a. s1 and s2 reference to the same String object
b. s1 and s2 reference to different String objects


a. s1 and s2 reference to the same String object
Since strings are immutable and are ubiquitous in programming, to improve efficiency and save memory, the JVM uses a unique instance for string literals with the same character sequence. Such an instance is called interned.

Computer Science & Information Technology

You might also like to view...

Which of the following choices should not be included in an assessment plan?

A. Product weaknesses B. Timeline and schedule C. Scope D. Resources required

Computer Science & Information Technology

What is the file extension used when a Word document will be commercially printed?

A) .xps B) .pdf C) .htm D) .docx

Computer Science & Information Technology

The QUARTILE.EXC function excludes quartiles 0 and 4

Indicate whether the statement is true or false

Computer Science & Information Technology

Correlation is a tool included on the Analysis ToolPak

Indicate whether the statement is true or false

Computer Science & Information Technology