Interview Questions

(TOP 24) OOPS Interview Questions

Written by bakair

OOPS Interview Questions

Object-oriented programming (OOP) is a computer psychology expression used to characterize a programming language that started expansion within the 1960’s. The term ‘object-oriented programming’ was first coined by Xerox PARC to designate a computer application that explains the methodology of exploitation objects because the basis for computation. By the 1980’s, OOP grew to prominence as the programming language of choice, explained by the success of C++. Now a days, OOPs like, C++, Java, C#,

Visual Basic.NET, Python, and JavaScript are popular OOP programming languages that any profession-orientated developer or programmer ought to be familiar with.

 

We have collected the most important questions about OOPS for you

 

Questions:

define OOPS?

answer. Object-oriented programming  is a language arranged throughout objects rather “actions” and data rather logic. Historically, a program has been seen as a logical method that receives input data, treats it, and generates output data.


 

what are  the  basic concepts of OOPS?

answer. the concepts of OOPS are as follows:.

Encapsulation

Abstraction.

Inheritance.

Polymorphism.


 

 define The term  class?

answer. The term ‘class’ points to the real written part of code that is used to describe the behavior of any class. So, a class is a static portion of code that consists of characteristics that don’t vary during the fulfilling of a program .


 

what’s an object?

answer. An object is a part of a program that recognizes how to do specific actions and how to mix with other components of the program. Objects are the fundamental parts of object-oriented programming.


 

what’s Encapsulation?

answer. is an approach used as an element of abstraction. Encapsulation points to the state of objects – objects encapsulate their state and protect it from the exterior; external users of the class communicate with it by its methods, but can not enter the classes element directly. So the class abstracts away the implementation parts related to its state


 

what’s Polymorphism?

answer. Polymorphism is nothing but assigning behavior or value during a subclass to one thing that was already declared within the main category. Simply, polymorphism takes more than one type.


 

what’s Inheritance?

answer. Inheritance is a concept wherever one category shares the structure and behavior outlined in another category. Inheritance applied on one category is named Single Inheritance, and if it depends on multiple categories, then it’s referred to as multiple Inheritance.


 

What are manipulators?

answer. Manipulators are the functions which may be utilized in conjunction with the insertion (<<) and extraction (>>) workS on an object. Examples  are endl and setw.


 

define a constructor?

answer. The constructor is a technique used to initialize the state of an object, and it gets invoked at the time of object creation. Rules constructor are:.

Constructor Name ought to be same as class name.

The constructor must haven’t any return type.


 

define Destructor?

answer. The destructor is a technique that is mechanically referred to as once the object is made of scope or destroyed. Destructor name is additionally same class name but with the tilde symbol before the name.


 

what’s Inline function?

answer. The inline function may be a technique utilized by the compilers and instructs to insert complete body of the function where that function is employed within the program source code.


 

what’s a virtual function?

answer. A virtual function is a member role of class and its practicality is overridden in its derived category. This function is enforced by employing a keyword referred to as virtual, and it is given throughout function declaration.

A virtual function is achieved in C++, and it is accomplished in C Language by using function pointers or tips to perform.


 

What is friend function?

answer. A friend function is a friend of a class that’s allowed to access to Public, non-public or protected data in this same category. If the function is outlined outside the class cannot access such data.

A friend is declared anyplace within the category declaration, and it can’t be affected by access management keywords like non-public, public or protected.


 

what’s function overloading?

answer. Function overloading is outlined as a traditional function, however, it’s the flexibility to perform completely different tasks. It allows the creation of many ways with an identical name that differ from one another by sort of input and output of the function.


 

define  operator overloading?

answer. Operator overloading shows the process implemented by the operator depends on the kind of operands presented to the operator. For example, (a) the sample left-shift operator << is overloaded to make current addition whenever a left operand is  a stream object such as cout; (b) the operator * could mean multiplication for 2 numbers of  indirection or types  if it goes on an address. C++ allows you enlarge operator overloading to  classes.

Operator overloading is related to function overloading, wherever you have several versions of the equivalent function separated by their parameter programs.

 

Example:

 

class complex {

 

double real,

 

imag; public: complex(double r, double i) : real(r),

 

imag(i) {} complex operator+(complex a, complex b);

 

complex operator*(complex a, complex b);

 

complex& operator=(complex a, complex b);


 

what’s an abstract class?

answer. An abstract category may be a class that can’t be instantiated. Creation of an object isn’t inherent with the abstract section, however it is inherited. an abstract class can contain solely Abstract technique.


 

what’s a ternary operator?

answer. The ternary operator is alleged to be an operator that takes 3 arguments. Arguments and results are of various data sorts, and it’s depends on the function. The ternary operator is additionally referred to as a conditional operator.


 

what’s the utilization of finalize method?

answer. Finalize methodology helps to perform cleanup operations on the resources that aren’t presently used. Finalize methodology is protected, and it’s accessible solely through this category or by a derived class.


 

What are differing kinds of arguments?

answer. A parameter may be a variable used throughout the declaration of the function or function and arguments are passed to the function, and it ought to match with the parameter outlined. There are 2 sorts of Arguments.

Call by value – value passed can get changed solely within the function, and it returns identical value no matter it’s passed it into the function.

 

Call by Reference – value passed can get changed in each within and outside the functions and it returns identical or completely different value.


what’s super keyword?

answer. Super keyword is used to invoke overridden methodology that overrides one among its superclass strategies. This keyword permits to access overridden strategies and conjointly to access hidden members of the superclass.

It conjointly forwards a call from a creator to a creator within the superclass.


 

what’s methodology overriding?

answer. Method overriding may be a feature that enables subcategory to provide an implementation of a method that’s already outlined within the main category. this can override the implementation within the superclass by providing identical methodology name, same parameter, and same return sort.


what’s an interface?

answer. An interface is an assortment of abstract methodology. If the category implements an inheritance, then thereby inherits all the abstract strategies of an interface.


what’s exception handling?

answer. The exception is an occasion that happens throughout the execution of a program. Exceptions are of any kind – Runtime exception, Error exceptions. Those exceptions are controlled properly through exception handling mechanism like attempt, catch and throw keywords.


What are tokens?

answer. Tokens are the smallest distinct and unique independent units used in C program.

When the C compiler is preparing the source code of a C program, a particular group of characters classified by white areas is described Tokens.

 

The various types of tokens used in C are :

Identifiers

Keywords

Variables

Constants

Other Separators

Operators

Strings

About the author

bakair

Leave a Comment