Question
Need help answering a few questions about object-oriented programming with Python 3! 1. What happens if we create an attribute whose name starts with __?
Need help answering a few questions about object-oriented programming with Python 3!
1. What happens if we create an attribute whose name starts with "__"?
A. Error
B. Nothing special
C. Python automatically appends _
D. It makes it impossible to access this attribute from outside the class
2. Creating a public interface is important because
A. It provides a set of methods for a user to use in order to ensure that attributes are set and gotten correctly.
B. It keeps attribute data private within the class
C. It allows for abstraction
D. It provides a set of alternative constructors for creating an instance of a class
3. All classes must define an __init__ method
A. True
B. False
4. Attributes of a class can only be basic data types (integer, floating point numbers, etc..)
A. True
B. False
5. The myMethod method of a class is defined below:
def myMethod(self, y) x = y
What is happening in the line x=y?
A. A syntax error occurs
B. The attribute x is assigned the value stored in y
C. An attribute of the object is created (and called x) and assigned the value stored in y
D. A local variable x is created and assigned the value stored in y
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started