Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fundamentals of Data Structures(Python) MCQ 1. A given class inherits all the me

ID: 3607120 • Letter: F

Question

Fundamentals of Data Structures(Python)
MCQ

1. A given class inherits all the methods and instance variables from its

a. Descendant classes

b. Ancestor classes

2. The number of methods available in a given class is generally

a. Less than or equal to the number of methods available to its parent class

b. Greater than or equal to the number of methods available to its parent class

3. A method in a given class can call the same method in an ancestor class by

a. Using the prefix self with the method’s name

b. Using the ancestor class name as a prefix with the method’s name

4. The name self always refers to

a. The object of the class used when that object was instantiated

b. The object of the class whose definition includes that use of self

5. The methods in an abstract class ideally

a. Call other methods on self to do their work

b. Include lots of references and assignments to instance variables

6. The methods most likely to be implemented in the AbstractCollection class are

a. __iter__, add, and remove

b. isEmpty, __len__, and __add__

Explanation / Answer

NOte:any doubt regarding the explanation drop a comment.I wil give some more explanation if needed.

GIve positive feedback when satisfied with thumbsup

--------------------------------------------------

1.B

When we are using inheritance then ancestor class properties and methods can be inherited

2.B

When a class inherits the properties of the parent class then

number of available will be equal to its super class. if sub class does not define its own methods

number of available will be greater than its super class. if sub class define its own methods also

3.none

we need to call the parent class overridden method by prefixing the super keyword

class Root:

    def draw(self):

        print ‘hi’;

class Shape(Root):

        def draw(self):

        print('bi’)

        super().draw()

4.a

self is like this keyword in java.It will keep the voice of the object .

That is it will keep the reference to object which invoked

It is passed automatically as the first parameter when you call a method on an instance,

Referencing a class or instance attribute from inside an instance method of the same class we use self

5.a

Methods in abstract class does not have any implementation.so to do their work they need implementation.The implementation for abstract methods can be done by sub classes

6.b

The most general in this case means their implementation need never be changed by subclass.