Python Programming - Encapsulation - Discussion
Discussion Forum : Encapsulation - General Questions (Q.No. 68)
68.
What does the following Python code demonstrate?
class Book:
def __init__(self, title, __author):
self.title = title
self.__author = __author
def get_author(self):
return self.__author
Answer: Option
Explanation:
The double underscore prefix before 'author' indicates that it is a private variable, demonstrating encapsulation by hiding the implementation details.
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