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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *