- Esecutori
-
Impara
Impara Python Esempi eseguibili, NumPy, pandas e altro Impara l'IA / Machine LearningReti neurali, ML e LLM da zero Impara C e C++ Puntatori, memoria, STL e C++ moderno Impara C#Fondamenti, OOP, LINQ, async ed esercizi .NET Impara MatplotlibGrafici a linee, barre, dispersione e torta con visualizzatori Impara RustOwnership, trait, gestione degli errori e thread Impara GoSlice, interfacce, goroutine e canali Algoritmi Python Ricerca, ordinamento, ricorsione e visualizzazioni O(n) Algoritmi C e C++ Confronta le implementazioni in C e C++ Programmazione per bambini Impara a programmare giocando!
- QuizNuovo
- SfideNuovo
- Per docentiNuovo
- Aggiornamenti
- Offrimi un caffè
Quiz di JavaScript: Classes & Inheritance
This JavaScript quiz covers the class syntax used in most modern code. You will predict output for subclasses, super calls, overridden methods and class fields, and spot the classic errors with this.
Domanda di esempio
Domanda 1 di 10What does this print?
class Animal {
constructor(name) { this.name = name; }
speak() { return `${this.name} makes a sound`; }
}
class Dog extends Animal {
speak() { return `${super.speak()}, woof`; }
}
console.log(new Dog("Rex").speak());
Mostra la risposta
A. Rex makes a sound, woof Dog has no constructor, so the default one passes "Rex" to Animal's constructor. super.speak() calls the parent method with the same this, then Dog appends its own text.
Cosa copre questo quiz
- Constructors, methods and class fields
extendsand callingsuper()andsuper.method()- Method overriding and dynamic
this - Losing
thiswhen a method is passed around - Private
#fields
Domande frequenti
Serve un account?
No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.
Posso rifarlo?
Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.