×


php and oops interview questions

What is Object Oriented Programming?

Object-oriented programming (OOP) is a programming language model organized around objects rather than functions as in procedural programming;
Objects are instances of classes, are used to interact with one another.

What are the advantages of OOPS concepts?

Major advantages of OOPS programming are;

  1. Simplicity: OOPS programming models on  objects, so the complexity is reduced and the program structure is better.
  2. Modularity: Each object forms a separate entity whose internal workings are decoupled from other parts of the system.
  3. Modifiability: Easy to modify
  4. Extensibility: Adding new features and modifying some existing ones is so much easier
  5. Maintainability: Objects can be maintained independantly
  6. Re usability: Objects can be reused in different programs.

What is data asbstraction

To show the needed/relevant information or details without showing all information which is not necessary is called abstraction.

 

What is data encapsulation

It is a concept of wrapping up or binding up related data members and methods in a single module known as Encapsulation. Encapsulation refers to a concept where we encapsulate all the data and member functions together to form an object.Achieved using public,private and protected methods and attributes

What is the difference between Procedural programming and OOPS? What is data asbstraction

To show the needed/relevant information or details without showing all information which is not necessary is called abstraction.

  1. Procedural language is based on functions but object oriented language is based  on objects.
  2. Procedural language gives importance on the sequence of function execution but object oriented language gives importance on states and behaviors of the objects.
  3. Procedural language exposes the data to the entire program but object oriented language encapsulates the data.
  4. Procedural language follows top down programming paradigm but object oriented language follows bottom up programming paradigm.
  5. Procedural language is complex in nature so it is difficult to modify, extend and maintain but object oriented language is less complex in nature so it is easier to modify, extend and maintain.
  6. Procedural language provides less scope of code reuse but object oriented language provides more scope of code reuse.

What is polymorphism

Polymorphism in Java has two types: Compile time polymorphism (static binding) and Runtime polymorphism (dynamic binding). Method overloading is an example of static polymorphism, while method overriding is an example of dynamicpolymorphism.

What is inheritance

A subclass can inherit the states and behaviors of it’s parent class is known as inheritance.

What is multiple inheritance

A child class inheriting states and behaviors from multiple parent classes is known as multiple inheritance.

 

What is Aggregation

Aggregation is also known as “HAS-A” relationship. When class Animal has a member reference variable of type Food  then the relationship between the classes Animal and Food is known as Aggregation. Aggregation can be understood as “whole to its parts” relationship.

Animal is the whole and Food is part.Food can exist without the Car. Aggregation is a weak association.

What is Composition

Composition is a special form of Aggregation where the part cannot exist without the whole. Composition is a strong Association. Composition relationship is represented like aggregation with one difference that the diamond shape is filled.

What is Dependency

When one class depends on another because it uses that at some point in time then this relationship is known as Dependency. One class depends on another if the independent class is a parameter variable or local variable of a method of the dependent class. A Dependency is drawn as a dotted line from the dependent class to the independent class with an open arrowhead pointing to the independent class.

Dependency injection alleviates these issues by inserting the dependencies through the dependent class’ constructor (“Constructor Injection”)

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *