Python Programming - Classes - Discussion
Discussion Forum : Classes - General Questions (Q.No. 40)
40.
Consider the following Python code:
class CoffeeShop:
def __init__(self, name):
self.name = name
class EspressoBar(CoffeeShop):
def __init__(self, name, serves_alcohol):
super().__init__(name)
self.serves_alcohol = serves_alcohol
# Create an instance of the EspressoBar class
my_espresso_bar = EspressoBar("Java Junction", False)
# Access and print attributes
print(my_espresso_bar.name)
print(my_espresso_bar.serves_alcohol)
What will be the output of the code?
Answer: Option
Explanation:
The code creates an instance of the `EspressoBar` class and prints the values of its attributes (`name`, `serves_alcohol`).
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers