nerdexam
Oracle

1Z0-803 · Question #68

Given a code fragment: What is the result?

The correct answer is D. Nothing is printed to the screen. Strings can not be compared with the usual <, <=, >, or >= operators, and the == and != operators don't compare the characters in the strings. So the first if statement fails. Equals works fine on strings. But it does not work here.The second if-statement also fails. The class do

Using Operators and Decision Constructs

Question

Given a code fragment:

What is the result?

Exhibit

1Z0-803 question #68 exhibit

Options

  • AThey match
  • BThey really match
  • CThey match
  • DNothing is printed to the screen

How the community answered

(60 responses)
  • A
    13% (8)
  • B
    3% (2)
  • C
    7% (4)
  • D
    77% (46)

Explanation

Strings can not be compared with the usual <, <=, >, or >= operators, and the == and != operators don't compare the characters in the strings. So the first if statement fails. Equals works fine on strings. But it does not work here.The second if-statement also fails. The class does not override the equals method so it uses the equals method of Object. If a and b are two objects from a class which doesn't override equals, then a.equals(b) is the

Topics

#code tracing#conditional statements#string comparison

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice