PCAP 31 03 PCAP Certified Associate Python Programmer · Free Practice Question Medium

Question 6

Q2000 - OOP


What is true about Object-Oriented Programming in Python?


(Select two answers)


  • A

    The arrows on a class diagram are always directed from a superclass towards its subclass.

  • B

    Encapsulation allows you to protect some data from uncontrolled access.

  • C

    An object is a recipe for a class.

  • D

    Inheritance is the relation between a superclass and a subclass.

Reveal correct answers

Correct answers: B, D

Explanation

Q2000 (Please refer to this number, if you want to write me about this question.)

A. The arrows on a class diagram in Object-Oriented Programming are typically directed from a subclass towards its superclass, indicating the inheritance relationship. This direction signifies that the subclass inherits properties and behaviors from the superclass, following the hierarchical structure of classes in Python.

B.

Encapsulation is a key principle in Object-Oriented Programming that involves bundling data (attributes) and methods (functions) that operate on the data into a single unit called an object. It allows you to control access to the data and helps in preventing unauthorized access or modification of the object's internal state.

C. An object is an instance of a class, not a recipe for a class. A class serves as a blueprint or template for creating objects, defining their attributes and behaviors. Objects are created based on classes and represent individual instances that possess the characteristics defined by the class.

D. Inheritance is a fundamental concept in Object-Oriented Programming that allows a subclass to inherit attributes and methods from a superclass. It establishes a relationship where the subclass is a specialized version of the superclass, enabling code reusability and promoting the concept of "is-a" relationships.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need