Encapsulation

36 MCQs

MCQs

36 questions · 30 min · 36 marks

Want to try first? Take the free Computer Science test: Networks Basics

Sample questions

The first 5 of 36. Try each one, then tap to see the answer.

  1. Question 1

    The OOP concept that hides data inside a class is:

    • AInheritance
    • BPolymorphism
    • CEncapsulation
    • DAbstraction
    Show answer

    Answer: C

    Encapsulation hides data inside a class and controls access to it.

  2. Question 2

    Encapsulation bundles data and methods into:

    • AMany separate files
    • BA database
    • CA table
    • DA single class
    Show answer

    Answer: D

    Data and methods are combined in a single unit called a class.

  3. Question 3

    The main idea behind encapsulation in OOP is:

    • ATo hide data inside a class and prevent unauthorised access
    • BTo create a flexible and adaptable programme
    • CTo reuse code from other classes
    • DTo allow multiple inheritance in classes
    Show answer

    Answer: A

    Encapsulation hides data and prevents unauthorised access.

  4. Question 4

    Encapsulation is best described as:

    • ACombining data and methods into a single unit and controlling access to data
    • BCombining multiple classes into one class
    • CInheriting methods from other classes
    • DAllowing objects to have multiple forms
    Show answer

    Answer: A

    Encapsulation bundles data and methods and restricts direct access to the data.

  5. Question 5

    Unlike Java or C++ Python:

    • AUses only public data
    • BHas no strict private or protected keywords
    • CCannot hide data at all
    • DRequires keywords for access control
    Show answer

    Answer: B

    Python relies on naming conventions instead of strict keywords.

More tests in Object Oriented Programming Using Python

Practise with a free account

Save your scores, see which chapters need work, and keep a notebook of every question you got wrong.

Create free account