Exam4Training

Which line of code properly declares the clothingItem class such that it inherits from Item?

Cloud Kicks has a class to represent items for sale in an online store, as shown below:

Class Item{

constructor (name, price){

this.name = name;

this.price = price;

}

formattedPrice(){

return ‘s’ + String(this.price);}}

A new business requirement comes in that requests a ClothingItem class that should have all of the properties and methods of the Item class but will also have properties that are specific to clothes.

Which line of code properly declares the clothingItem class such that it inherits from Item?
A . Class ClothingItem implements Item{
B . Class ClothingItem {
C . Class ClothingItem super Item {
D . Class ClothingItem extends Item {

Answer: D

Exit mobile version