nerdexam
Oracle

1Z0-805 · Question #60

Which is a key aspect of composition?

The correct answer is B. Method delegation. In an object-oriented design of a Java program, the way in which you model objects that contain other objects is with composition, the act of composing a class out of references to other objects. With composition, references to the constituent objects become fields of the…

Advanced Class Design

Question

Which is a key aspect of composition?

Options

  • AUsing inheritance
  • BMethod delegation
  • CCreating abstract classes
  • DImplementing the composite interface

How the community answered

(26 responses)
  • A
    15% (4)
  • B
    73% (19)
  • C
    4% (1)
  • D
    8% (2)

Explanation

In an object-oriented design of a Java program, the way in which you model objects that contain other objects is with composition, the act of composing a class out of references to other objects. With composition, references to the constituent objects become fields of the containing object. To use composition in Java, you use instance variables of one object to hold references to other Oracle 1Z0-805 Exam The relationship modeled by composition is often referred to as the "has-a" relationship. Delegation involves re-exporting methods; in a composition relationship, the inner objects methods may be used only privately and not re-exposed.

Topics

#composition#method delegation#design patterns#class design

Community Discussion

No community discussion yet for this question.

Full 1Z0-805 Practice