Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 95)
95.
What is the primary purpose of the following Python class?
class Car:
def __init__(self, model, __speed):
self.model = model
self.__speed = __speed
def get_speed(self):
return self.__speed
Answer: Option
Explanation:
The get_speed() method provides controlled and read-only access to the private variable '__speed', demonstrating encapsulation.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers