Tags:

OOPS interview questions and answers

By Dhananjay yadav January 19, 2018
What is OOPS(Object Oriented Programming System)?
OOPS, that is Object Oriented Programming System is a modularized system of programming. Chunks of programs are designed in such a manner that we can reuse them, modify them and also can rework on them.

What is a class?
A class is a collection or a group to represent similar type entities having identical properties and behavior.A class does not exist in physical but a concept to visualize real-world entities.

What is an object?
An object is a blueprint of a class. It is a prototype what class defines. When we have a working object we can say it is an instance.

How can we differentiate between Procedural Programming System and OOPS?
An object-oriented language is based on modules that are Object but procedural programming has no such concepts.
OOPS is able to encapsulate data and member functions in a single block but procedural programming language represents a discrete structure.
A procedural language is based on top-down approach whereas object-oriented language is based on the bottom-up approach of the algorithm.
A procedural language is rigid in nature, but OOPS provide flexibility and reusability of code.

What are the basic pillars of OOPS?
Fundamental pillars of OOPS and are as follows:
1-Abstraction
Hiding the sensitive data or the way of implementation, but revealing the necessary data to the end user.It limits the scope of variables, methods.Abstraction is to implement the security features in OOPS and so in application.
2-Encapsulation
Encapsulation is the wrapping of data and data functions in a single block of codes. It contains the data definitions and behavior definition in a single block that is Class.
3-Inheritance
Inheritance provides flexibility features to OOPS. It allows a class to share its functions, variables to other classes and the classes that will be using the functions definitions and data variables of other class called child class, and this phenomenon is called Inheritance.
4-Polymorphism
Polymorphism is a way to reimplement the methods in child-class or in a subclass that is already implemented in the parent class.It gives flexibility to an object to represent it and to use its many forms as per the function definitions in classes.

What is a constructor in OOPS?
The constructor is a method which is called automatically when an Object of a class is instantiated.The constructor has the same name as that of the class and it does not return.

What is the basic difference between overloading and overriding?
Overloading
When two methods are defined with the same name in a single class but they must have different signatures, then this phenomenon is known as Overloading.
overriding
When a method defined in the parent class is reimplemented by subclass or child class, then this phenomenon is known as overriding.

Difference between class and an object?
A class is a definition and object is a prototype of that definition.An object contains states and behaviors and a class is a template of an object. An object is an instance of a class and it is working model of a definition that we can call a class.

What are the specifiers?
Specifiers or modifiers define the scope of variables and methods in OOPS.They implement a secure structure and access level in the architecture of an application.There is some important access specifiers are as follows:
Private:
Restricts the access to the class itself. Even Child or subclass are also not allowed to use private functions and data.
Protected:
A protected function or variable or member is accessible within the class and within the child class or subclass only. It cannot be accessible from anywhere else.
Public:
It provides an open accessibility to members. Either within the class or within child class or from anywhere in the script, It will be accessible.

What is a destructor?
the destructor is a function which can be called automatically when an object is deleted.

Post Tags:

No Comment to " OOPS interview questions and answers "