Multiple choice technology web technology

internal class Piston {} internal class Engine { private Piston[] myPistons = new Piston[4]; public bool Ignition() { //some code } }public class Car { private Engine myEngine = new Engine(); public void Start() { //put in keys etc.. if (myEngine.Ignition()) { //some more code507 } } What concept does the above sample code demonstrate?

  1. Delegation

  2. Composition

  3. Polymorphism

  4. Inheritance

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The code demonstrates Composition - a 'has-a' relationship between classes. Car contains an Engine object (myEngine), and Engine contains an array of Piston objects (myPistons). This is object composition, not inheritance (is-a relationship), delegation (forwarding calls), or polymorphism (same interface different implementations).