Courseiva

200-901 Software Development and Design Practice Question

A developer is designing a Python class to model a network device. The class should prevent direct modification of the device's IP address after it is set, while still allowing the address to be read. Which implementation achieves this encapsulation requirement?

⚠ Common exam trap

The trap here is assuming that a single underscore provides real protection, when it is only a naming convention that Python does not enforce.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Define the IP address as a private attribute named __ip_address and provide only a getter method.

Using a double-underscore prefix triggers name mangling, which discourages direct external access, and exposing only a getter method allows reading the address without providing a way to change it. A public attribute, a single-underscore convention, or a class variable all permit modification or do not represent per-instance state, so they fail the encapsulation requirement.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    Define the IP address as a public attribute named ip_address.

    Why it's wrong here

    A public attribute can be read and modified freely by any code, so it does not prevent direct modification. This fails the requirement to restrict changes after the address is set. Encapsulation in Python typically involves name mangling or properties to control access, not simply exposing a public attribute.

  • ✓

    Define the IP address as a private attribute named __ip_address and provide only a getter method.

    Why this is correct

    Prefixing the attribute with double underscores triggers name mangling, making it harder to access directly from outside the class. Providing only a getter method allows reading the address while omitting a setter prevents direct modification. This satisfies the encapsulation requirement of read-only access after initialization.

  • ✗

    Define the IP address as a protected attribute named _ip_address and document that it should not be changed.

    Why it's wrong here

    A single underscore is a convention indicating internal use, but it does not enforce any restriction. External code can still modify _ip_address directly. Since the requirement is to prevent modification, relying on documentation alone is insufficient and does not achieve true encapsulation.

  • ✗

    Define the IP address as a class variable shared by all instances.

    Why it's wrong here

    A class variable is shared across all instances of the class, so changing it affects every device object. This is the opposite of what is needed for per-device IP addresses and provides no encapsulation. It also allows modification, failing the requirement to prevent changes after the address is set.

About these practice questions

This 200-901 question is part of Courseiva's 975-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Cisco exam blueprint

This 200-901 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 200-901 exam.