PCPP 32 10x PCPP Certified Professional Python Programmer 1 · Free Practice Question Easy
Question 1
Which of the following answers will create an empty class? (Select three)
-
A
- class Student: pass
-
B
- class Company(object):
- pass
-
C
- class Car:
-
D
- class Person:
- pass
Reveal correct answers
Correct answers: A, B, D
A.
This code also creates an empty class named Student using the pass statement. It follows the same principle as the previous answer, creating a class without any additional code or functionality.
B.
This code creates an empty class named Company that inherits from the base object class. By including (object) in the class definition, it explicitly indicates that the class inherits from the built-in object class. Again, the pass statement is used to create an empty class body without any additional code or functionality.
C.
This code creates a class named Car but it is not considered an empty class because it lacks the pass statement or any other code within its class body. An empty class should have a placeholder statement like pass to indicate that it has no further content. Therefore, this answer is incorrect.
D.
This code creates an empty class named Person by using the pass statement. The pass statement is a placeholder that allows creating a class without adding any additional content or functionality to it.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
