0% found this document useful (0 votes)
28 views3 pages

JS OOPS 11 (QS)

The document provides an overview of Object-Oriented Programming (OOP) in JavaScript, explaining key concepts such as classes, objects, constructor functions, and the prototype chain. It highlights the benefits of OOP, including improved code organization and reusability, and discusses inheritance and the use of the 'super' keyword. Additionally, it clarifies the distinction between constructors and classes, as well as the role of the 'new' keyword in creating object instances.

Uploaded by

priyanshu230404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

JS OOPS 11 (QS)

The document provides an overview of Object-Oriented Programming (OOP) in JavaScript, explaining key concepts such as classes, objects, constructor functions, and the prototype chain. It highlights the benefits of OOP, including improved code organization and reusability, and discusses inheritance and the use of the 'super' keyword. Additionally, it clarifies the distinction between constructors and classes, as well as the role of the 'new' keyword in creating object instances.

Uploaded by

priyanshu230404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

JS (OOP)

[email protected]
Summary Sheet

Qs1. What is Object Oriented Programming (OOP)?


Ans. Object-Oriented Programming (OOP) is a programming paradigm in computer
science that relies on the concept of classes and objects. It is used to structure a
software program into simple, reusable pieces of code blueprints (usually called
classes), which are used to create individual instances of objects.

Qs2. What are some benefits of using OOP in JavaScript?


Ans. Some benefits of using OOP in JavaScript includes:
a. Improved code organization (structure of code)
b. Reusability of code
c. Better maintainability of code
d. Closeness to real-world objects

Qs3. What is the difference between an object and a class in JavaScript?


Ans. Objects in JS is a standalone entity, with properties, methods and a type. It can be
created directly from functions or through constructor functions.
Class in JS acts as a blueprint for creating objects.

Qs4. What is a constructor function in JS?


Ans. constructor function is a special function that is used to create & initialize objects
in JS. When a new object is created using a constructor function, it is automatically
assigned a set of properties and methods that are defined within the function.

Qs5. What is a prototype chain in JavaScript?


Ans. Every object in JavaScript has a built-in property, which is called its prototype.
The prototype is itself an object, so the prototype will have its own prototype, making
what's called a prototype chain. The chain ends when we reach a prototype that has
null for its own prototype.

[email protected]
Qs6. What is the difference between a constructor and a class in JavaScript?
Ans. A constructor is a function that creates an object, while a class is a blueprint for
creating objects. Classes define the framework whereas, constructor actually creates
the objects & initializes them.
(In JavaScript, classes are syntactic sugar over constructor functions.)

Qs7. Why is the “new” keyword used in JavaScript?


Ans. The 'new' keyword is used to create an instance of an object. When used with a
constructor function, it creates a new object and sets the constructor function's 'this'
keyword to point to the new object.

Qs8. What is Inheritance in OOP?


Ans. Inheritance in OOP is defined as the ability of a class to derive properties and
characteristics from another class while having its own properties as well.

Qs9. What is the “super” keyword in JS?


Ans. The super keyword in JavaScript acts as a reference variable to the parent class.
It is mainly used when we want to access a variable, method, or constructor in the
base class from the derived class.

Qs10. What will be the output for the following code:


[email protected]
Ans. The output will be “Square area is 16” as the child class (Square) implementation
of area() function will override parent class (Box) implementation of the function with
the same name.

You might also like