Constructors in Python Quiz
FREE Online Courses: Enroll Now, Thank us Later!
Quiz Summary
0 of 10 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 10 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
-
Question 1 of 10
1. Question
Constructors ____ an object.
CorrectIncorrect -
Question 2 of 10
2. Question
How many parameters do non-parameterized constructors contain?
CorrectIncorrect -
Question 3 of 10
3. Question
What default parameter does a constructor contain?
CorrectIncorrect -
Question 4 of 10
4. Question
A constructor can only return ___.
CorrectIncorrect -
Question 5 of 10
5. Question
Which of the following statement(s) is/are true?
Statement 1: __init__ instantiates the created object.
Statement 2: Python first invokes the __new__ and then invokes the __init__ method.
CorrectIncorrect -
Question 6 of 10
6. Question
What is the output of the below code?
Code
>>> class SomeClass:
>>> def __init__(self):
>>> print(“Instantiated”)
>>> print(SomeClass())
CorrectIncorrect -
Question 7 of 10
7. Question
Read the code and choose the correct option.
Code
>>> class RandomClass:
>>> rand = 123
>>> print(RandomClass().rand)
Output
123
The above code contains
CorrectIncorrect -
Question 8 of 10
8. Question
Read the code and choose the correct option.
Code
>>> class Fruit:
>>> def __init__(self, taste):
>>> self.taste = taste
>>> print(Fruit(“Sweet”).taste)
Output
Sweet
The above code contains
CorrectIncorrect -
Question 9 of 10
9. Question
What is the output of the below code?
Code
>>> class Phone:
>>> count = 0
>>> def __init__(self, brand, model, os):
>>> self.brand = brand
>>> self.model = model
>>> self.os = os
>>> Phone.count += 1
>>> iPhone = Phone(“Apple”, 11, “iOS”)
>>> one_plus = Phone(“One Plus”, “Nord”, “Android”)
>>> iPhone.model = f”{one_plus.model}{Phone.count}”
>>> print(iPhone.model)
CorrectIncorrect -
Question 10 of 10
10. Question
What is the output of the below code?
Code
>>> class Dual:
>>> def __init__(self):
>>> print(“Constructor 1”)
>>> def __init__(self):
>>> print(“Constructor 2”)
>>> obj = Dual()
CorrectIncorrect