InfyTQ OOPS Concepts (Python) Quiz 2

Question 1

Time: 00:00:00
The output of the following code will be:

class X:

    def __init__(self):

        self.multiply(19)

        print(self.z)

 

    def multiply(self, z):

        self.z = 4 * z;

class Y(X):

    def __init__(self):

        super().__init__()

 

    def multiply(self, z):

        self.z = 2 * z;

obj = Y()

19

19

76

76

error

error

38

38

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Which one is true?

A non-private method in a superclass can be overridden

A non-private method in a superclass can be overridden

A subclass method can be overridden by the superclass

A subclass method can be overridden by the superclass

A private method in a superclass can be overridden

A private method in a superclass can be overridden

Overriding isn’t possible in Python

Overriding isn’t possible in Python

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
 Predict the Output:

class Engineer:

    def __init__(self):

        self.total = 97

        self.__cpi = 8.75

    def display(self):

        print(self.total)

obj=Engineer()

print(obj._Engineer__cpi)

97

97

8.75

8.75

8.7

8.7

8

8

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Which one is not true about protected class members?

They begin with one underscore

They begin with one underscore

They can be accessed by subclasses

They can be accessed by subclasses

They can be accessed by name mangling method

They can be accessed by name mangling method

They can be accessed within a class

They can be accessed within a class

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
The output of the following code is:

class sub:

    def __init__(self):

        self.colour = None

        self._shape = "Square" 

 

    def display(self, s):

        self._shape = s

obj=sub()

print(obj._sub_shape)

The program runs fine because name mangling has been properly implemented

The program runs fine because name mangling has been properly implemented

Error because the member shape is a protected member

Error because the member shape is a protected member

Error because the proper syntax for name mangling hasn’t been implemented

Error because the proper syntax for name mangling hasn’t been implemented

Error because the member shape is a private member

Error because the member shape is a private member

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Private data field from the given code is:

def Demo:

def __init__(self):

    __X = 1

    self.__Y = 1

    self.__Z__ = 1

    __T__= 1

__X

__X

__Y

__Y

__Z__

__Z__

__T__

__T__

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
From the given options which one is not a fundamental feature of oops? 

Encapsulation

Encapsulation

Inheritance

Inheritance

Instantiation

Instantiation

Polymorphism

Polymorphism

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/0

Accuracy

0%

Comments