0% found this document useful (0 votes)
12 views1 page

Oops 1

Uploaded by

jamefik256
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Oops 1

Uploaded by

jamefik256
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1. State the difference between constructor and destructor in python.

ANS-Constructor: A constructor is a special method defined using __init__() that is called


automatically when an object is created. It initializes the object's attributes and sets up any
necessary properties.

Destructor: A destructor is a special method defined using __del__() that is called


automatically when an object is about to be destroyed, typically when it goes out of scope or
is deleted. Destructors are less commonly used in Python because of its built-in garbage
collection.

2. State the difference between Public and Private access modifier in python.

ANS-Public: Public attributes and methods can be accessed from both inside and outside the
class. In Python, by default, all attributes and methods are public unless specified otherwise.
Private: Private attributes and methods are intended to be used only within the class. In
Python, they can be made private by prefixing the attribute or method name with double
underscores (__). This adds name mangling, making it harder to access from outside the
class.

3. Explain Method overriding in python Inheritance.

ANS-Method overriding allows a subclass to provide a specific implementation of a method


that is already defined in its superclass. It’s useful in cases where the inherited method
doesn’t meet the specific needs of the subclass.

4. What is abstraction in OOPS and how does it simplify complex systems?

ANS-Abstraction is an OOP concept that involves hiding complex implementation details and
exposing only the essential features. By focusing on the high-level functionality rather than
the intricate workings, abstraction allows users to interact with an object or system without
needing to understand its complexity.

You might also like