nerdexam
Oracle

1Z0-803 · Question #52

Given the following code: What will make this code compile and run?

The correct answer is E. Change line 5 to the following:. price.price =4; is correct, not price=4; The attribute price of the instance must be set, not the instance itself.

Java Basics

Question

Given the following code:

What will make this code compile and run?

Exhibit

1Z0-803 question #52 exhibit

Options

  • AChange line 2 to the following:
  • BChange line 4 to the following:
  • CChange line 4 to the following:
  • DChange line 5 to the following:
  • EChange line 5 to the following:
  • FChange line 5 to the following:
  • GChange line 5 to the following:
  • HThe code compiles and runs properly; no changes are necessary

How the community answered

(40 responses)
  • A
    3% (1)
  • E
    85% (34)
  • G
    5% (2)
  • H
    8% (3)

Explanation

price.price =4; is correct, not price=4; The attribute price of the instance must be set, not the instance itself.

Topics

#compilation errors#syntax correction#static keyword#access modifiers

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice