# Knowledge check: Introduction to Object-Oriented Programming in Javascript

1. **What will print out when the following code runs?**
    
    ```javascript
    class Cake {
        constructor(lyr) {
            this.layers = lyr + 1;
        }
    }
    
    var result = new Cake(1);
    console.log(result.layers);
    ```
    
    * 1
        
    * <mark>2</mark>
        
    * 3
        
    * 4
        
2. **When a class extends another class, this is called \_\_\_\_\_\_\_\_\_\_\_\_.**
    
    * <mark>Inheritance</mark>
        
    * Extension
        
3. **What will print out when the following code runs?**
    
    ```javascript
    class Animal {
        constructor(lg) {
            this.legs = lg;
        }
    }
    
    class Dog extends Animal {
        constructor() {
            super(4);
        }
    }
    
    var result = new Dog();
    console.log(result.legs);
    ```
    
    * 0
        
    * undefined
        
    * null
        
    * <mark>4</mark>
        
4. **What will print out when the following code runs?**
    
    ```javascript
    class Animal {
    
    }
    
    class Cat extends Animal {
        constructor() {
        super();
        this.noise = "meow";
        }
    }
    
    var result = new Animal();
    console.log(result.noise);
    ```
    
    * <mark>undefined</mark>
        
    * null
        
    * ""
        
    * meow
        
5. **What will print out when the following code runs?**
    
    ```javascript
    class Person {
        sayHello() {
            console.log("Hello");
        }
    }
    
    class Friend extends Person {
        sayHello() {
            console.log("Hey");
        }
    }
    
    var result = new Friend();
    result.sayHello();
    ```
    
    * Hello
        
    * <mark>Hey</mark>
