Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

How do you define a class in JavaScript?

View

What is the purpose of the constructor method in a class?

View

How do you create a new instance of a class?

View

What is the purpose of the extends keyword?

View

What is a static method in a class?

View

What is the result of this code: class MyClass { constructor() { this.name = "Test"; } } const obj = new MyClass(); console.log(obj.name);?

View

Can you define methods in a class without the function keyword?

View

How do you call a parent class constructor from a subclass?

View

Can you use getters and setters in a class?

View

What is the difference between an instance method and a static method?

View

How do you define a class in JavaScript?

class MyClass()
class MyClass {}
class = MyClass {}
function MyClass {}

What is the purpose of the constructor method in a class?

To destroy class instances
To create new methods in a class
To initialize an instance of a class
To define static methods

How do you create a new instance of a class?

let obj = new MyClass();
let obj = MyClass();
let obj = create MyClass();
let obj = new class();

What is the purpose of the extends keyword?

To add new methods to a class
To inherit properties and methods from another class
To export a class
To make a class async

What is a static method in a class?

A method that cannot be inherited
A method that is called without instantiating the class
A method that can only be called once
A method that automatically destroys an object

What is the result of this code: class MyClass { constructor() { this.name = "Test"; } } const obj = new MyClass(); console.log(obj.name);?

"Test"
undefined
null
It throws an error

Can you define methods in a class without the function keyword?

Yes, in ES6+ you don't need the function keyword inside a class
No, methods must always use function
Yes, but only for arrow functions
No, the class will throw an error without function

How do you call a parent class constructor from a subclass?

parent()
super()
this()
parent.constructor()

Can you use getters and setters in a class?

No, getters and setters are only for objects
Yes, using get and set keywords
No, ES6+ classes don't support them
Yes, but only in async classes

What is the difference between an instance method and a static method?

Instance methods are only called once, static methods multiple times
Static methods belong to the class, instance methods belong to the object
Instance methods cannot access the this keyword, static methods can
Static methods are used for class inheritance