InfyTQ OOPS Concepts (Python) Quiz 1

Question 1

Time: 00:00:00
To create an object ______ is used.

class

class

constructor

constructor

User-defined functions

User-defined functions

In-built functions

In-built functions

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

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
_____ represents an entity in the real world with its identity and behaviour.

An object

An object

An operator

An operator

A class

A class

A method

A method

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

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
class pizza:
def __init__(self, money):
self.money = money
obj=pizza(99)
obj.amount=4
obj.total=2
print(obj.amount+len(obj.__dict__))

The output of the following code will be:

6

6

7

7

99

99

105

105

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

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
class test():
def __repr__(self):
return 'This is called'
def __str__(self):
return 'No! This is called'
s=test()
print(s)

This is called

This is called

Nothing is printed

Nothing is printed

Error

Error

No! This is called

No! This is called

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

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
 hasattr(obj, name) is used to?

access the attribute of the object

access the attribute of the object

delete an attribute

delete an attribute

check if an attribute exists or not

check if an attribute exists or not

set an attribute

set an attribute

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

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
 The output to the following code will be:
class Engineer:
    'Base class for all students'
    def __init__(self, id_no, score):
       self.id_no = id_no
       self.score = score
    def display (self):
       print("Roll no : ", self.id_no,  ", Grade: ", self.score)
print(Engineer.__doc__)

None

None

Nothisg is printed

Nothisg is printed

Base class for all students

Base class for all students

Error

Error

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

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
 predict the output
class Demo:
    def __init__(self):
        self.x = 0
class Derived_Demo(Demo):
    def __init__(self):
        self.y = 1
def main():
    b = Derived_Demo()
    print(b.x,b.y)
main()

 

0 1

0 1

1 0

1 0

0 0

0 0

Error

Error

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

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Determine the type if Inheritance:
class prep():
    pass
class insta():
    pass
class python(prep, insta):
    pass

Multi-level inheritance

Multi-level inheritance

Multiple inheritance

Multiple inheritance

Hierarchical inheritance

Hierarchical inheritance

Single-level inheritance

Single-level inheritance

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

Please login to submit your explanation

Start

Question 9

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

A non-private method in a superclass can be overridden

A non-private method in a superclass can be overridden

A derived class is a subset of a superclass

A derived class is a subset of a superclass

The value of a private variable in the superclass can be changed in the subclass

The value of a private variable in the superclass can be changed in the subclass

When invoking the constructor from a subclass, the constructor of the superclass is automatically invoked

When invoking the constructor from a subclass, the constructor of the superclass is automatically invoked

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

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
 What will be the output of the following code:
class D:
    def __init__(self,x):
        self.x = x
    def count(self,x):
        self.x = self.x+1
class C(D):
    def __init__(self, y=0):
        D.__init__(self, 5)
        self.y = y
    def count(self):
        self.y += 1     
def main():
    obj = C()
    obj.count()
    print(obj.x, obj.y)
main()

5 0

5 0

5 1

5 1

0 1

0 1

Error

Error

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/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

Comments

One comment on “InfyTQ OOPS Concepts (Python) Quiz 1”