OOP Flashcards
OOP stands for?
Object Oriented Programming.
What is OOP?
Programming paradigm based on the concept of objects, which can contain data in the form of fields and code in the form of methods.
What are the key principles of OOP?
Encapsulation
Inheritance
Polymorphism
Abstraction
What is Encapsulation?
Bundling of data and methods that operate on that data into a single unit or class. It restricts direct access to some of the object’s components, which is a way to enforce data hiding.
What is Inheritance?
Mechanism where a new class inherits the properties and behavior of another class. This helps in code reusability.
What is Polymorphism?
Ability of different classes to respond to the same function or method call in their own way. It can be achieved via method overloading or overriding.
What is Abstraction?
Hiding the complex implementation details and showing only the essential features of the object. It simplifies interaction with objects.
What is a class?
A class is a blueprint for creating objects. It defines a datatype by bundling data and methods that work on the data into one single unit.
What is an object?
An object is an instance of a class. When a class is defined, no memory is allocated until an object is created from the class.
What is the difference between a class and an object?
A class is a blueprint that defines the attributes and methods of an object whereas an object is an instance of a class. It holds the actual data and can use the methods defined in the class.
What are the two types of Polymorphism?
Method Overloading (runtime polymorphism) and Method Overriding (compile-time polymorphism).
What is method overloading?
Method overloading refers to the ability to define multiple methods in the same class with the same name but different parameter lists.
What is method overriding?
Method overriding allows a subclass to provide a specific implementation of a method that is already defined in its superclass.
What’s the difference between Abstraction and Encapsulation?
Abstraction focuses on hiding complexity by only exposing relevant information whereas Encapsulation focuses on controlling access to the data by using access modifiers.
What is an abstract class?
An abstract class is a class that cannot be instantiated and is meant to be inherited by other classes. It typically contains one or more abstract methods that must be implemented by its subclasses.