The @property decorator is used in Python to define a getter method for a class attribute, allowing controlled access.
Discuss About this Question.
Which access specifier in Python is used to indicate that a variable or method should only be accessed within the same class?
A:
Public
B:
Private
C:
Protected
D:
Global
Answer:B
Private access specifier in Python is denoted by a single underscore (_), and it indicates that the variable or method should only be accessed within the same class.
Discuss About this Question.
In Python, what is encapsulation?
A:
The process of hiding the implementation details of an object and exposing only the necessary functionalities
B:
The process of combining data and methods into a single unit
C:
The process of creating multiple instances of a class
D:
The process of inheriting attributes and behaviors from another class
Answer:A
Encapsulation in Python involves bundling the data and methods of a class and controlling access to the internal details, exposing only the necessary functionalities.
Discuss About this Question.
Ad Slot (Above Pagination)
Install ExamAdept
Fast access — add this app to your device.
To install on iPhone/iPad: tap Share → Add to Home Screen.
Discuss About this Question.