Which of the following statements is true about private attributes in a Python class?
- Private attributes are accessible and modifiable outside the class, just like public attributes.
- Private attributes are denoted by a double underscore prefix, such as "__private". They can be accessed and modified outside the class.
- Private attributes are denoted by a single underscore prefix, such as "_private". They are intended for internal use within the class.
- Private attributes are inaccessible from outside the class, making them more secure.
Private attributes in Python are typically denoted by a single underscore prefix (e.g., "_private"). While they can still be accessed from outside the class, the convention is to treat them as non-public and for internal use.
Loading...
Related Quiz
- How can you create a new instance of a custom class and assign it to a variable in Python?
- In Python’s unittest framework, the ____ method is used to compare whether two values are equal.
- The ____ method is used to pre-fetch the next value of a generator object.
- The _____ method in Python is used to delete the object and perform the cleanup activities.
- Django's ____ system is used to maintain user sessions and manage user authentication.