
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
33 questions
GCSE: ICT Applications 1 (Self Led)
Presentation
•
12th Grade
35 questions
DATABASE SYSTEM (MODULE #2)
Presentation
•
University
34 questions
Gamifed activities
Presentation
•
KG
30 questions
Anti Korupsi Bab 1, 2, dan 3
Presentation
•
University
30 questions
ENGLISH 12 - WORD FORMATION
Presentation
•
12th Grade
27 questions
IDIK4009 - Pengembangan Bahan Ajar - TTM 2
Presentation
•
University
36 questions
Unit 4.1 : Computer Network
Presentation
•
KG - University
32 questions
Chapter 8 Printer part 4 Mr. Burnside 3/18/21
Presentation
•
Professional Development
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade