Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

What is encapsulation in OOP?

View

Which of the following is used to denote a private attribute in Python?

View

How can a private attribute be accessed from outside the class?

View

Which of the following violates encapsulation?

View

What is the purpose of setter methods?

View

Which keyword is used to indicate a protected attribute?

View

What is the use of property() function in Python?

View

How does Python implement encapsulation?

View

Which of the following is true for encapsulation?

View

What happens if you try to access a private attribute?

View

What is encapsulation in OOP?

Combining data and methods
Inheriting classes
Dividing data into small pieces
Creating private methods

Which of the following is used to denote a private attribute in Python?

Single underscore (_)
Double underscore ()
No symbol is needed
The word private

How can a private attribute be accessed from outside the class?

Directly with . notation
Through a public method
It cannot be accessed
By prefixing with _

Which of the following violates encapsulation?

Using getter methods
Accessing private data directly
Using setters to update data
Defining public methods

What is the purpose of setter methods?

To hide methods
To access private data
To modify private attributes
To create new objects

Which keyword is used to indicate a protected attribute?

protected
Single underscore _
private
public

What is the use of property() function in Python?

To create immutable attributes
To implement getter and setter methods
To encapsulate classes
To define new methods

How does Python implement encapsulation?

With public and private keywords
By using underscores
Using the keyword hidden
Python does not support encapsulation

Which of the following is true for encapsulation?

It increases code complexity
It ensures data hiding
It forces all attributes to be public
It is used only in inheritance

What happens if you try to access a private attribute?

The program runs without issues
It raises an AttributeError
It prints None
It shows a warning