but if an object of the subclass is used to invoke the methodthen the version in the child class will be executed in other wordsit is the type of the object being referred to (not the type of the reference variablethat determines which version of an overridden method will be executed exampleclass parent()constructor def __init__(self)self value "inside parentparent' show method def show(self)print(self valuedefining child class class child(parent)constructor def __init__(self)self value "inside childchild' show method def show(self)print(self valuedriver' code obj parent(obj child(obj show(obj show(outputinside parent inside child data encapsulation encapsulation is one of the fundamental concepts in objectoriented programming (oopit describes the idea of wrapping data and the methods that work on data within one unit this puts restrictions on accessing variables and methods directly and can prevent the accidental modification of data to prevent accidental changean object' variable