Friday, July 6, 2018

OOPS Basic

What are the core concepts of OOPS?
  1. Class
  2. Objects and Methods
  3. Code Reusability Module Concepts
    1. Inheritance
    2. Has - A Relationship
    3. Polymorphism
      1. Method Overloading
      2. Method Overriding
  4. Security Module Concepts
    1. Abstraction
    2. Encapsulation
    3. Data Hiding
    4. Tightly Coupled Classes
  5. Composition
  6. Association
  7. Aggregation
What is multiple inheritance ?
  1. A child class inheriting states and behaviors from multiple parent classes is known as multiple inheritance.
What is Diamond inheritance problem?
  1. In case of multiple inheritance, suppose class A has two subclasses B and C, and a class D has two super classes B and C.
  2. If a method present in A is overridden by both B and C but not by D then from which class D will inherit that method B or C? This problem is known as diamond problem. 
What is the difference between Object Oriented Programming Language and Object Based Programming Language?
  1. Object Oriented Programming languages like Java and C++ follow concepts of OOPS like- Encapsulation, Abstraction, Polymorphism and Inheritance etc.
  2. Object Based Programming languages follow some features of OOPS but they do not provide support for Polymorphism and Inheritance. Egg. JavaScript, VBScript etc.
  3. Object Based Programming languages provide support for Objects and you can build objects from constructor. 
    1. These languages also support Encapsulation. These are also known as Prototype-oriented languages.
Can we create an object of abstract class?
  1. No we cannot create an object of abstract class but we can create a Reference to it.
Is Inheritance Tightly coupled or Loosely coupled?
  1. Inheritance is tightly coupled since any changes to the Parent class impacts the child class.
  2. Inheritance is  "Is-A" relationship.
  3. For a loosely coupled architecture we must create a "Has-A" architecture where we create an object of a class in another class.