Which is a key aspect of composition?
A.
Creating abstract classes
B.
Implementing the composite interface
C.
Using inheritance
D.
Method delegation
Which is a key aspect of composition?
Which is a key aspect of composition?
A.
Creating abstract classes
B.
Implementing the composite interface
C.
Using inheritance
D.
Method delegation
D
D.
OCA/OCP Java SE 7 Programmer I & II Study Guide (Kathy Sierra, Bert Bates)
Object Composition Principles, 548 Chapter 10: Advanced OO and Design Patterns
public class MailerBox implements Box, Mailer { // MailerBox IS-A Box
private Box box; // MailerBox HAS-A Box
You can see the composition part, the terminology for object composition:
MailerBox both IS-A Box and HAS-A Box .
MailerBox is composed of a Box and delegates to Box for logic.
We delegate to Box to actually do the work. This is called method forwarding
or method delegation. These two terms mean the same thing.
Hi,Gelete, looks the concept of method delegation is that “one object delegate its behavior and state to another object”, interesting thing is : why the name is method delegation, not object delegation?