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
Public access specifier
Private access specifier
Protected access specifier
Global variable
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:

Your comments will be displayed after verification.