This topic contains a solution. Click here to go to the answer

Author Question: What is the output of the following code?public class Test { public static void main(String[] args) ... (Read 33 times)

joblessjake

  • Hero Member
  • *****
  • Posts: 555

Question 1

Which of the following statements is preferred to create a string "Welcome to Java"?
◦ String s = new String("Welcome to Java");
◦ String s; s = "Welcome to Java";
◦ String s = "Welcome to Java";
◦ String s; s = new String("Welcome to Java");

Question 2

What is the output of the following code?

public class Test {
public static void main(String[] args) {
String s1 = "Welcome to Java!";
String s2 = s1;
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");
}
}

◦ s1 and s2 reference to the same String object
◦ s1 and s2 reference to different String objects


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by joblessjake on May 6, 2020

jennafosdick

  • Sr. Member
  • ****
  • Posts: 345
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 39% of students answer this correctly




joblessjake

  • Member
  • Posts: 555
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


isabelt_18

  • Member
  • Posts: 342
Reply 3 on: Yesterday
Wow, this really help

 

Did you know?

Patients who have been on total parenteral nutrition for more than a few days may need to have foods gradually reintroduced to give the digestive tract time to start working again.

Did you know?

The term bacteria was devised in the 19th century by German biologist Ferdinand Cohn. He based it on the Greek word "bakterion" meaning a small rod or staff. Cohn is considered to be the father of modern bacteriology.

Did you know?

There are 60,000 miles of blood vessels in every adult human.

Did you know?

Throughout history, plants containing cardiac steroids have been used as heart drugs and as poisons (e.g., in arrows used in combat), emetics, and diuretics.

Did you know?

Your heart beats over 36 million times a year.

For a complete list of videos, visit our video library