What gets printed to the screen by the following segment of code? String str1 = "hello"; String str2 = "world"; if (!str1.equals(str2)) { System.out.println(str1+" "+str2); } else { System.out.println(str2+" "+str1); hello world world hello Nothing gets printed by this segment

EBK JAVA PROGRAMMING
8th Edition
ISBN:9781305480537
Author:FARRELL
Publisher:FARRELL
Chapter16: Graphics
Section: Chapter Questions
Problem 2RQ
icon
Related questions
Question
What gets printed to the screen by the following
segment of code?
String str1 = "hello";
String str2 = "world";
if (!str1.equals (str2)) {
System.out.println(str1+" "+str2);
}
else {
System.out.println(str2+" "+str1);
%3D
hello world
world hello
Nothing gets printed by this segment
Transcribed Image Text:What gets printed to the screen by the following segment of code? String str1 = "hello"; String str2 = "world"; if (!str1.equals (str2)) { System.out.println(str1+" "+str2); } else { System.out.println(str2+" "+str1); %3D hello world world hello Nothing gets printed by this segment
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Methods of StringBuilder class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT