[Python OOP] Inheritance, special function

Quiz
•
Computers
•
12th Grade
•
Hard
Zheng Liu
Used 4+ times
FREE Resource
7 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Look at the code snippet in the screenshot. If you run the screenshot, what will happen?
It will raise an error: Rectangle class does not have method "printMe" defined.
It will raise an error: Rectangle class is empty. Python does not allow that.
It will run, and print "Shape: generic shape" on screen.
It will run, but nothing will be printed on screen.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Look at this code snippet (screenshot). What will happen if you run it?
An error will occur: Rectangle class has two "printMe" methods. Cannot resolve which method to use.
It will print "Shape: generic shape" on screen
It will print "Shape: Rectangle" on screen
It will print two lines:
Shape: generic shape
Shape: Rectangle
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Look at the code snippet (screenshot). What happens if you run it?
An error will occur.
It will print "Shape Rectangle"
It will print:
Shape: Rectangle
shape: generic shape
It will print:
Shape: generic shape
Shape: rectangle
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Look at the code snippet. Note there's a blank "______" in the snippet. Suppose we would like to make "Shape" an abstract class, by keeping "printMe" method not implemented. Which option is correct to fill in the blank?
return NotImplemented
raise NotImplementError("printMe method not implemnted!")
return NotImplementedError("printMe method not implemnted!")
return None
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Recall that Python str class support "+" operation: "abc" + "ef" => "abcef". Which special method must the str class have implemented?
def __str_ _
def str
def __add_ _
def __eq_ _
6.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
This code snippet shows the definition of "Stack" class. Which option(s) of the following is correct to get the size of the stack object s (assign to variable n)?
n = s.size()
n = s.len()
n = len(s)
n = len(s.__list)
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Look at the snippet for Stack class. What's the time complexity of "push", "pop" and "get" methods? (N: size of stack)
push: O(1)
pop: O(1)
get: O(1)
push: O(N)
pop: O(N)
get: O(1)
push: O(1)
pop: O(1)
get: O(N)
push: O(N)
pop: O(N)
get: O(N)
Similar Resources on Wayground
10 questions
Câu hỏi Python

Quiz
•
9th - 12th Grade
11 questions
P1.3 - Solution planning

Quiz
•
10th Grade - University
10 questions
File handling

Quiz
•
12th Grade
10 questions
Python quiz

Quiz
•
10th Grade - Professi...
10 questions
Python Flow Control

Quiz
•
9th - 12th Grade
12 questions
Computer Science Academy Quiz

Quiz
•
12th Grade
10 questions
Python Boolean and If

Quiz
•
9th - 12th Grade
11 questions
Casting in Java

Quiz
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade
19 questions
AP CSP Unit 1 Review (code.org)

Quiz
•
10th - 12th Grade