You are on page 1of 4

 

Home Study tools  My courses  My books My folder Career Life

home / study / engineering / computer science / computer science questions and answers / 

briefly...

Question: Briefly explain inheritance, multilevel inheritance


and multiple inheritance using your own pract...
Find solutions for your homework

Show transcribed image text

Answers

Anonymous
answered this

Inheritance is a concept in Object oriented programming in which


one class inherits methods/attributes
from other class. The class
whose methods are inherited are called the parent class or base
class and the
class which inherits the properties are called child
class or derived class.

Multilevel inheritance is a concept in which the classes are


derived hierarchially and it can follow upto any
depth.

for eg. class a inherited by class b and class b by class c...


so on...

Multiple inheritance is a concept in which multiple base classes


can be inherited by a child class.

for eg class a , class b inherited by class c

Practical eg.:

Inheritance:

class A:

def f1(self):

print("Parent class.")
class B(A):

def f2(self):

print("Child class.")

ob1 = B()

ob1.f1()

ob1.f2()

Multiple inheritance:

class A:

def f1(self):

print("Parent1 class.")

class B:

def f2(self):

print("Parent2 class.")

class C(A,B):

def f3(self):

print("Child class.")

ob1 = C()

ob1.f1()

ob1.f2()

ob1.f3()

output:

Parent1 class.

Parent2 class.

Child class.

multi-level:

class A:

def f1(self):

print("Parent1 class.")

class B(A):

def f2(self):

print("Child1 class-Parent2 class.")

class C(B):

def f3(self):

print("Child2 class.")

ob1 = C()

ob2 = B()

ob2.f1()

ob1.f2()

ob1.f3()

output:

Parent1 class.

Child1 class-Parent2 class.

Child2 class.

0 Comments
Questions viewed by other students
Was this answer helpful? 1

I need the solution in 50 mins. I will upvote you surely.


Briefly explain inheritance, multilevel inheritance
and multiple
inheritance
using your own practical example.
See answer

(5) 1. Briefly explain inheritance, multilevel inheritance and multiple inheritance using your own practical
example.
See answer

Show more 

COMPANY

LEGAL & POLICIES

CHEGG PRODUCTS AND SERVICES

CHEGG NETWORK

CUSTOMER SERVICE

© 2003-2022 Chegg Inc. All rights reserved.

You might also like