OOPs in Python MCQs Exercise II


Ques 1 OOPs


What is the output of the following Python Code?


class student:
    def __init__(self, roll_no,college):
        self.__roll_no=roll_no
        self.college=college
student1 = student(18345354332,"CSIT COE")
print(student1.__roll_no)

  a) 18345354332
  b) Error
  c) 18345354332
  d) None of these.


b is the correct option





Ques 2 OOPs


What is the output of the following Python Code?


class student:
    def __init__(self, roll_no,college):
        self.__roll_no=roll_no
        self.college=college
student1 = student(18345354332,"CSIT COE")
student1.branch="Information Technology"
student1.__branch="Information Technology"
print(student1.branch)

  a) Information Technology
  b) Error
  c) 18345354332
  d) None of these.


a is the correct option