Oracle 1Z0-808 Exam question no. 74

Q.– Given: 

String stuff = "TV"; 
String res = null; 
if (stuff.equals("TV")) { 
        res = "Walter"; 

else if (stuff.equals(("Movie")) { 
       res = "White"; 
} else { 
      res = "No Result";
}

Which code fragment can replace the if block? 

A) res = stuff.equals("TV") ? stuff.equals("Movie") ? "Walter" : "White" : "No Result"; 

B) res = stuff.equals("TV") ? "Walter" : stuff.equals("Movie") ? "White" : "No Result"; 

C) res = stuff.equals("TV") ? "Walter" else stuff.equals("Movie") ? "White" : "No Result"; 

D) stuff.equals("TV") ?  res="Walter" : stuff.equals("Movie") ? res = "White" : res = "No Result";


⧪ please give your answer in a comment section.

Post a Comment

4 Comments