Fun Puzzles!-JavaScript dated 13/03/2023

Hello Everyone!

Please answer the following questions.

1.Which of the following best describes encapsulation in JavaScript?

a) A technique for keeping the implementation details of an object hidden from the outside world

b) A way of combining multiple objects into a single object

c) A way of sharing properties and methods between objects

d) A method of creating new objects based on existing ones

2.What is inheritance in JavaScript?

a) A way of sharing properties and methods between objects

b) A method of creating new objects based on existing ones

c) A technique for keeping the implementation details of an object hidden from the outside world

d) A way of combining multiple objects into a single object

3.Which of the following is an example of encapsulation in JavaScript?

a) Using the “this” keyword to access object properties

b) Using the “extends” keyword to inherit from a base class

c) Using private variables and functions within a module

d) Using the “super” keyword to call methods from a parent class

4.Which of the following is an example of inheritance in JavaScript?

a) Creating a new object using the “new” keyword and a constructor function

b) Using the “Object.assign” method to copy properties from one object to another

c) Using the “prototype” property to add methods to an object’s prototype

d) Using the “class” keyword to define a new class that extends an existing one

5.What is the main advantage of encapsulation and inheritance in JavaScript?

a) It allows for better organization and abstraction of code

b) It makes code easier to read and understand

c) It reduces the amount of code needed to achieve a particular task

d) It improves performance and reduces memory usage

Have a Happy Learning

Thanks & Regards

Teaching Assistant,
Dharshini M.

1 Like

answer for the following question

1.b
2.b
3.a
4.a
5.b

@robertravi3660 Thank you for your valuable response. :grinning: