OOP in Python
Quiz
•
Computers
•
University
•
Practice Problem
•
Hard
Tomasz Szturo
Used 21+ times
FREE Resource
Enhance your content in a minute
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
___________ are special methods that can be used to create and initialize an object
Answer explanation
Constructors are special methods in object-oriented programming languages, including Python, that are automatically called when a new object of a class is created. In Python, the constructor method is defined as init(self, ...)
2.
FILL IN THE BLANK QUESTION
1 min • 2 pts
Fill in the blank to correctly define an initialization method for a class named Book that takes two parameters (besides self): title and author, and assigns them to instance variables.
Answer explanation
The correct way to define the initialization method in Python involves specifying self as the first parameter in the method definition to refer to the instance of the class. The self parameter is also used to assign values to instance variables.
3.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
What does an object consist of?
Methods
Attributes
Procedures
Variables
Answer explanation
An object in Object-Oriented Programming consists of attributes and methods. Attributes hold the data (the state of the object), and methods define the behavior (what the object can do).
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The ability of a programming language to process objects differently depending on their class is called ...
Encapsulation
Inheritance
Polymorphism
Instantiation
Attributes
Answer explanation
Polymorphism allows objects of different classes to be treated through a common interface, enabling methods to use objects of any class that implements that interface.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You can instantiate an object more than once?
True
False
Answer explanation
Yes, you can instantiate an object more than once, creating multiple instances of a class, each with potentially unique attributes.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following statements correctly creates an instance of a class named Vehicle in Python?
class Vehicle: new_vehicle = Vehicle()
new_vehicle = Vehicle.class()
new_vehicle = Vehicle()
Vehicle new_vehicle = Vehicle()
Answer explanation
In Python, objects are instantiated from classes by calling the class as if it were a function, like Vehicle().
This creates a new instance of the class and assigns it to a variable (new_vehicle in this case).
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is true about inheritance in Python?
Inheritance allows a class to inherit attributes and methods only from a single parent class.
Inheritance allows a class to inherit attributes and methods from multiple parent classes, known as multiple inheritance.
Inheritance is a mechanism where a class can copy methods from modules and packages.
Inheritance is not supported in Python due to its dynamic nature.
Answer explanation
Python supports multiple inheritance, allowing a class to inherit from more than one base class. This feature enables the derived class to acquire attributes and methods from all the base classes it extends.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
10 questions
ทำความรู้จักกับภาษาไพทอน
Quiz
•
University
20 questions
Programming Concepts in C - Quiz-II
Quiz
•
University
18 questions
PBO Inheritance Episode 2
Quiz
•
University
18 questions
AI 900 - pt 1
Quiz
•
University
15 questions
Aptitude Assessment 2
Quiz
•
University
20 questions
Programming2
Quiz
•
University
10 questions
Programacion Orientada a Objetos
Quiz
•
12th Grade - University
10 questions
PF Unit 10
Quiz
•
9th Grade - University
Popular Resources on Wayground
10 questions
Honoring the Significance of Veterans Day
Interactive video
•
6th - 10th Grade
9 questions
FOREST Community of Caring
Lesson
•
1st - 5th Grade
10 questions
Exploring Veterans Day: Facts and Celebrations for Kids
Interactive video
•
6th - 10th Grade
19 questions
Veterans Day
Quiz
•
5th Grade
14 questions
General Technology Use Quiz
Quiz
•
8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
Circuits, Light Energy, and Forces
Quiz
•
5th Grade
19 questions
Thanksgiving Trivia
Quiz
•
6th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
9 questions
Principles of the United States Constitution
Interactive video
•
University
18 questions
Realidades 2 2A reflexivos
Quiz
•
7th Grade - University
10 questions
Dichotomous Key
Quiz
•
KG - University
25 questions
Integer Operations
Quiz
•
KG - University
7 questions
What Is Narrative Writing?
Interactive video
•
4th Grade - University
20 questions
SER vs ESTAR
Quiz
•
7th Grade - University
