Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

PYTHON QUESTIONS : PART 11

which piece of code creates an empty class?

class A:

      return

class A:

      pass

class A:

It is not possible to create an empty class.

SHOW ANSWER

What are the methods which begin and end with two underscore characters called?

Special methods

In-built methods

User-defined methods

Additional methods 

SHOW ANSWER

What is the output of the following piece of code?

class stud:

    def __init__(self,roll_no,grade):

        self.roll_no=roll_no

        self.grade=grade

    def dislay(self):

        print("roll no:",self.roll_no,"grade:",self.grade)

stud1=stud(34,'S')

stud1.age=7

print(hasattr(stud1,'age'))

Error as age isn't defined

True

False

7

SHOW ANSWER

Which of the following statements is wrong about inheritance?

Protected memebers of a class can be inherited

The inheriting class is called as a subclass

Private members of a class can be inherited and accessed

Inheritance is one of the features of oop

SHOW ANSWER

What is the output of the following piece of code?

class A():

          def disp(self):

                   print("A disp()")

class B(A):

          pass

obj = B()

obj.disp()

Invalid syntax for inheritance

Error because when object is created, argument must be passed

Nothing is printed

A disp() 

SHOW ANSWER

What is the output of the following piece of code?

class A:

    def one(self):

        return self.two

    def two(self):

        return 'A'

class B(A):

    def two(self):

        return 'B'

obj1=A()

obj2=B()

print(obj1.two(),obj2.two())

AA

AB

BB

An exception is thrown 

SHOW ANSWER

What type of inheritance is illustrated in the following piece of code?

class A():

          pass

class B(A):

          pass

class C(B):

          pass

Multi-level inheritance

Multiple inheritance

Hierarchical inheritance

Single-level inheritance

SHOW ANSWER

What is the output of the following piece of code when executed in the Python shell?

class A:

    pass

class B(A):

    pass

obj=B()

print(isinstance(obj,A))

True

False

Wrong syntax for isinstance()method

Invalid method for classes

SHOW ANSWER

The assignment of more than one function to a particular operator is ---------

Operator over-assignment

Operator overriding

Operator overloading

Operator instance

SHOW ANSWER

Which of the following is not a class method?

Non-static

Static

Bounded

Unbounded

SHOW ANSWER

Which of the following best describes polymorphism?

Ability of a class to derive members of another class as a part of its own definition

Means of bundling instance variables and methods in order to restrict access to certain class members

Focuses on variables and passing of variables to functions

Allows for objects of different types and behaviour to be treated as the same general type

SHOW ANSWER

A class in which one or more methods are only implemented to raise an exception is an abstract class. True or False?

True

False

SHOW ANSWER

Overriding means changing behaviour of methods of derived class methods in the base class. Is the statement true or false?

True

False

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in