31.) What is the output of the following code?
class Vehicle {
constructor() {
this.type = "Car";
}
}
class Bike extends Vehicle {
constructor() {
super();
this.type = "Bike";
}
}
const bike = new Bike();
console.log(bike.type);
32.) What is the output of this code?
function Shape() {
this.type = "shape";
}
Shape.prototype.getType = function () {
return this.type;
};
const circle = new Shape();
circle.type = "circle";
console.log(circle.getType());
33.) What does the following code output?
class Parent {
constructor() {
this.name = "Parent";
}
}
class Child extends Parent {
constructor() {
super();
delete this.name;
}
}
const child = new Child();
console.log(child.name);
34.) What is the output of the following code?
class Animal {
constructor() {
this.legs = 4;
}
}
Animal.prototype.sound = "roar";
const cat = new Animal();
cat.sound = "meow";
delete cat.sound;
console.log(cat.sound);
35.) What is the output of this code?
class Gadget {
constructor() {
this.type = "gadget";
}
}
Gadget.prototype.showType = function () {
return this.type;
};
const phone = new Gadget();
Gadget.prototype.type = "generic gadget";
console.log(phone.showType());