
DCS2103 - Week 13 (Inheritance)
Presentation
•
Computers
•
University
•
Practice Problem
•
Easy
Yasmin Basiran
Used 1+ times
FREE Resource
24 Slides • 13 Questions
1
2
3
Multiple Choice
Which of the following best describes inheritance in object-oriented programming?
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Multiple Choice
In Python, what does the super() function do?
20
Multiple Choice
What is the output of:
class Parent:
def init(self):
self.value = 5
class Child(Parent):
def init(self):
super().__init__()
self.value = 10
c = Child()
print(c.value)
21
Multiple Choice
What is the output of
class A:
def init(self, val):
self.val = val
class B(A):
def init(self):
super().__init__(10)
b = B()
print(b.val)
22
Multiple Choice
Is there an error in this code?
class A:
def init(self):
self.x = 5
class B(A):
def init(self):
self.y = 10
print(B().x)
23
Multiple Choice
If a child class defines its own init but doesn’t call super().__init__(), what happens?
24
25
26
27
28
29
30
Multiple Choice
Which of the following is true about multiple inheritance in Python?
A class can inherit from multiple parent classes
Python does not support multiple inheritance
Only methods are inherited, not attributes
Constructors cannot be inherited
31
Multiple Choice
What is the output of
class Engine:
def init(self, hp):
self.hp = hp
class Car:
def init(self):
self.engine = Engine(150)
c = Car()
print(c.engine.hp)
32
Multiple Choice
What is the main benefit of composition over inheritance?
33
Draw
Draw a multiple inheritance diagram: Bird and Animal as parents, FlyingAnimal as child.
34
Open Ended
Explain composition in Python with a real-life example.
35
Open Ended
What is one concept, function, or trick in Python that you are most proud of learning?
36
Open Ended
What one piece of advice would you give someone taking this course next semester?
37
Show answer
Auto Play
Slide 1 / 37
SLIDE
Similar Resources on Wayground
32 questions
PREPOSITIONS
Presentation
•
University
33 questions
Roles of Transport Trade Associations and Transport User Bodies
Presentation
•
University
33 questions
Freedom of Expression
Presentation
•
University
32 questions
Hybrid Course Design
Presentation
•
University
33 questions
Lines/Levels & Gradients
Presentation
•
Professional Development
28 questions
Verbals
Presentation
•
University
28 questions
Session 4: Differentiated instruction and Engagement strategies.
Presentation
•
University - Professi...
30 questions
CUM6010 Activities
Presentation
•
University
Popular Resources on Wayground
20 questions
"What is the question asking??" Grades 3-5
Quiz
•
1st - 5th Grade
20 questions
“What is the question asking??” Grades 6-8
Quiz
•
6th - 8th Grade
10 questions
Fire Safety Quiz
Quiz
•
12th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
34 questions
STAAR Review 6th - 8th grade Reading Part 1
Quiz
•
6th - 8th Grade
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
47 questions
8th Grade Reading STAAR Ultimate Review!
Quiz
•
8th Grade
Discover more resources for Computers
15 questions
LGBTQ Trivia
Quiz
•
University
36 questions
8th Grade US History STAAR Review
Quiz
•
KG - University
25 questions
5th Grade Science STAAR Review
Quiz
•
KG - University
16 questions
Parallel, Perpendicular, and Intersecting Lines
Quiz
•
KG - Professional Dev...
20 questions
5_Review_TEACHER
Quiz
•
University
10 questions
Applications of Quadratic Functions
Quiz
•
10th Grade - University
10 questions
Add & Subtract Mixed Numbers with Like Denominators
Quiz
•
KG - University
20 questions
Block Buster Movies
Quiz
•
10th Grade - Professi...