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 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...

The Cascade Update Related Fields checkbox is irrelevant if the primary key has an AutoNumber field type

Indicate whether the statement is true or false

Computer Science & Information Technology

A(n) ________ effect is used to make text or graphics move or change while displayed off the screen

Fill in the blank(s) with correct word

Computer Science & Information Technology

What are some safeguards that OS makers supply to combat malware?

What will be an ideal response?

Computer Science & Information Technology

Define the root of a tree.

What will be an ideal response?

Computer Science & Information Technology