0% found this document useful (0 votes)
3 views2 pages

Exercise 4

The document contains a series of questions related to Object-Oriented Programming (OOP) concepts in Python, including the definitions of objects and classes, instantiation of classes, and expected outputs of specific code snippets. It also asks for a comparison between procedural and object-oriented approaches and requests an explanation of various aspects of OOP. The questions are designed to test understanding of fundamental OOP principles in Python programming.

Uploaded by

mjbro5233
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Exercise 4

The document contains a series of questions related to Object-Oriented Programming (OOP) concepts in Python, including the definitions of objects and classes, instantiation of classes, and expected outputs of specific code snippets. It also asks for a comparison between procedural and object-oriented approaches and requests an explanation of various aspects of OOP. The questions are designed to test understanding of fundamental OOP principles in Python programming.

Uploaded by

mjbro5233
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise IV

1. Which of the following is correct with respect to OOP concept in Python?

A. Objects are real world entities while classes are not real.
B. Classes are real world entities while objects are not real.
C. Both objects and classes are real world entities.
D. Both object and classes are not real.
2. The correct way to instantiate the above Dog class is:

class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
A.Dog.__init__("Rufus", 3)

B.Dog.create("Rufus", 3)

C.Dog()

D.Dog("Rufus", 3)

3. What will be the output of the following Python code?

class test:
def __init__(self,a="Hello World"):
self.a=a

def display(self):
print(self.a)
obj=test()
obj.display()
a) The program has an error because constructor can’t have default arguments
b) Nothing is displayed
c) “Hello World” is displayed
d) The program has an error display function doesn’t have parameters

4. What will be the output of the following Python code?

class test:
def __init__(self,a):
self.a=a
def display(self):
print(self.a)
obj=test()
obj.display()
a) Runs normally, doesn’t display anything
b) Displays 0, which is the automatic default value
c) Error as one argument is required while creating the object
d) Error as display function requires additional argument

5.Difference between Procedural Approach And Object oriented approach?


6.Briefly explain the different aspects of Oops concept ?

You might also like