OOdesign Flashcards
What is OOP
Object Oriented Programming; Programs are considered as a collection of objects. Each object is nothing but an instance of a class
What are the basic concepts of OOP
Abstraction, Encapsulation, Inheritance, Polymorphism
What is a class
A class is a representation of a type of object; it is the blueprint that describes the details of an objet
What is an object
An object is an instance of a class; it has its own state, behavior and identity
Encapsulation
Encapsulation is an attribute of an object, and it contains all data which is hiddent. The hidden data can be restricted to the members of that class
Polymorphism
Polymorphism is nothing but assigning behavior or value in a subclass to something that was already declared in the main class. Simply, polymorphism takes more than one form.
Inheritance
Inheritance is a concept where one class shares the structure and behavior defined in another class. Ifinheritance applied on one class is called Single Inheritance, and if it depends on multiple classes, then it is called multiple Inheritance.
Constructor
Constructor is a method used to initialize the state of an object, and it gets invoked at the time of object creation
Function Overloading
Function overloading is defined as a normal function, but it has the ability to perform different tasks. It allows the creation of several methods with the same name which differ from each other by the type of input and output of the function.
Abstract Class
An abstract class is a class which cannot be instantiated. Creation of an object is not possible with an abstract class, but it can be inherited. An abstract class can contain only Abstract method. Java allows only abstract method in abstract class while for other languagesit allows non-abstract method as well
Call by value
Value passed will get modified only inside the function, and it returns the same value whatever it is passed it into the function
Call by reference
Value passed will get modified in both inside and outside the functions and it returns the same or different value
Method Overridding
Method overriding is a feature that allows sub class to provide implementation of a method that is already defined in the main class. This will overrides the implementation in the superclass by providing the same method name, same parameter and same return type.
Interface
An interface is a collection of abstract method. If the class implements an inheritance, and then thereby inherits all the abstract methods of an interface
Difference between overloading and overridding
Overloading is static binding whereas Overriding is dynamic binding. Overloading is nothing but the same method with different arguments , and it may or may not return the same value in the same class itself. Overriding is the same method names with same arguments and return types associates with the class and its child class.