1. What is the output of the following code?

class MyClass:
    x = 5

obj = MyClass()
print(obj.x)

A) None

B) 5

C) Error

D) 0

B) 5 (Class attributes are accessible via instances.)


2. Which method is called when an object is created?

A) __init__

B) __new__

C) __start__

D) __call__

A) __init__ (Constructor method initializes the object.)


3. What is the purpose of self in Python classes?

A) Refers to the parent class

B) Refers to the instance of the class

C) A reserved keyword for static methods