QUESTION IMAGE
Question
question 19
what will the following code print?
python
class
cat:
def init(self, name, age);
self.name = name
self.age = age
def meow(self):
print(\meow!\)
my_cat = cat(\whiskers\, 3)
my_cat.meow()
○ cat
○ meow!
○ whiskers
○ 3
question 20
which of the following is not a good practice in oop?
○ using meaningful names for classes and attributes
○ keeping methods short and focused
○ exposing all attributes publicly
○ using inheritance to avoid code duplication
Step1: Analyze Question 19 code
The code defines a Cat class with an init method (setting name and age) and a meow method that prints "Meow!". An instance my_cat is created, then my_cat.meow() is called.
Step2: Determine Question 19 output
Calling my_cat.meow() executes the meow method, which prints "Meow!".
Step3: Analyze Question 20 OOP practices
Good OOP practices include meaningful names, short focused methods, and using inheritance to reduce duplication. Exposing all attributes publicly violates encapsulation (a core OOP principle), so it is not a good practice.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
Question 19: B. Meow!
Question 20: C. Exposing all attributes publicly