OOPS Interview Questions

OOPS Interview Questions

0 6555

Coding Tag provides you a bunch of Top 30 OOPS concept interview questions. These C++ interview questions are taken from basic to advance level concepts to crack any MNC interview.

1) What do you mean by programming language?

As we all know that a computer is an electronic device used for computation tasks. It does not have its own brain to do work. To make computer to do any task we need to provide him some instructions and those instructions are known as a program and the person who is giving that instructions are known as a programmer and the language in which these instructions are written is known as a programming language.

There are many programming languages available nowadays for e.g. C, JAVA, PYTHON, and many more. C++ is also one of them.


2) When was the C++ discovered?

Bjarne Stroustrup in 1979.


3) C++ Language consists of?

C++ is known as C with classes as it contains features of C and OPPS concepts of Simula 67 and in 1983 the C with classes is renamed as C++ language


4) What are the main benefits of the C++ programming language?

  • Web browsers
  • Games
  • For building other programming languages like JAVA
  • GUI Applications
  • Compilers
  • Simulation Software
  • Image editing software like ADOBE and many more

5) Name the basic tools used to create any C++ application?

The archiver, linker, and compilers are the three basic tools required to convert the source files of C++ into an executable file.


6) What is the requirement of IDE in C++?

You need to pass input and output files along with important configuration as a text in command-line tools to get specific outputs from specific programs. Invoking these tools with repeated text as the time of developing any program is more deadening and time-consuming.

To solve this problem IDE is used to describe the binary values and organizing the source files with buttons as it provides the graphical interface.

Most common C++ IDE are:

  • Code Warrior
  • Code Block
  • Visual C++

7) Namespace in C++?

The namespace can be referred to as a declarative region or part, in which various elements of the program can be placed.it is used to manage or organize the large program.


8) What is the extension of the C++ file?

.CPP is the extension of the file saved in C++

For example codingtag.cpp


9) Before using any variable if it is not defined it will generate an error as in the given program?

Int age=7;
Float avg;
Cout<<b<<endl;

Yes, it will generate an error because b is not declared.


10) What is the need for object-oriented programming language if there is already a readable C programming language?

C is the structural and procedural language as it contains a proper structure such as looping, decision-making constructs, function, and various applications still there is the problem in C language because of the following reason:

the approach of C language is to divide the huge logic into a set of functions i.e. overall emphasis is on functionality not on data inside it, the program is manageable on certain limits.

less secure

Example:

If you have 45000 lines of code, even you break down this huge code into 5 functions. Each of these 5 functions contains 9000 lines. Even these functions are not manageable because we are not able to debug the 9000 lines of code at once.

When we want to share data among these 5 functions. We need to pass an argument to the same data it will waste memory, to avoid this, some data is made global and but global data can be accessed by any function it will reduce security.

Every MNC company cares about data, not on functionality, and invest in the security of data they don't want to place data public. This is the reason why object-oriented language is used.


11) What do you mean by object-oriented programming?

The activity of simulating the real-life things in the code is known as object-oriented programming.


12) What do you mean by objects in C++?

The object can be referred to as the small part of code representing a real-time entity or real-life things. every object has its own characteristics known as attributes and functionality can be called its behavior.

Examples of Attributes can be type, color, or dimensions. In programming language attributes are mapped with variables and functions are mapped with function. attributes correspond to data members whereas behaviors correspond to function.


13) Is it possible for the virtual function to be achieved in the C programming language?

Yes, it is possible with pointers to function or function pointers.


14) What is a virtual function?

A virtual function is known as the member function of the class that can be redefined in derived classes. The implementation can be done with the keyword known as virtual that can be given while declaring a function.

Virtual functions are primarily used to attain Runtime polymorphism.


15) Friend Function?

Data hiding is an interesting concept found in an object-oriented language. With that data hiding, non-member function is not allowed to access private and protected information of an object.

The programmer needs to write lengthy and complex code to access that data. You can access that data with the help of a friend function. It can be declared in any place in the class declaration and allowed to access the public, protected, and private data in the same class.


16) What is operator overloading?

Operator overloading means multiple jobs. In C++, it is known as the form of polymorphism where the operator is overloaded to achieve meaningful operation on the user-defined data type.

We can assume + basic application of addition is to add numeric values i.e. 5+9 =14; it is possible to add objects also with + symbol i.e. obj7= obj2 + obj5 with the operator overloading.

Thus, it can be overloaded to achieve various addition on different data types such as String(concatenation), Integer, etc.


17) List a few names of Operators not overloaded in C++?

  • Dot operator-.
  • scope operator-::
  • member pointer selector - *
  • Pointer-to-member operator (.*)
  • Ternary operator - ?:
  • (typeid)object type operator
  • (Sizeof)object size operator

18) The Ternary operator in C++?

The ternary operator is known as a conditional operator that precedes three arguments. Data types and results contain different data types depends upon the function.

The syntax of the ternary operator is Exp2? exp3: exp4

The expression exp2 will always evaluate. It depends on the outcome of exp2 is responsible for the Execution of exp3 and exp4. If the result of exp1 is non zero exp3will be evaluated, otherwise exp4 will be evaluated.


19) Abstraction?

Abstraction is one of the considerable concepts of OOPS as it is used to display only the relevant and required details of an object.

Example:

When anyone wants to enjoy the air of fan in summer, he wants to switch on the fan; it is not required for him to show all the features inside that fan. Whatever is required to switch on the fan will be displayed by the use of abstract class


20) Is it possible without creating an instance, you can able to call the base method in C++?

Yes, it is possible with the use of inheritance, but the method should be a static method.


21) Name the different access specifiers found in the C++ language?

  • PUBLIC
  • PRIVATE
  • PROTECTED
  • FRIEND
  • PROTECTED FRIEND

22) What are sealed modifiers?

Sealed modifiers are identical to access modifiers but the only difference is that they cannot be inherited and can be easily applied to the events, properties, and methods except static members and static methods


23) What is the default access modifier found in class in OOPS?

Private


24) What is a pure virtual function?

A pure virtual function is a virtual function that cannot be defined but can be overridden in the derived class.

The operator=0 can be used to declare any virtual function as a pure virtual function.


25) Is it possible to override the method with a virtual keyword represented in the method definition?

Yes


26) Is the reuse mechanism possible in OOPS?

Yes, it is possible with the inheritance concept of OOPS


27) What is 'this' pointer?

'THIS' pointer is referred to as the current object of a class. It also differentiates the global object with a current object.


28) Is it possible to call the function of the C program in the C++ program?

With the use of the extern "C" declaration, it is possible to call the c function in the C++ program.


29) What do you mean by mutable modifiers in C++?

As we know that the data members and member functions of a constant object and class cannot be modified but if we want some modifications, the mutable keyword can be used.


30) What do you mean by reference variable in C++?

A reference variable can be called another name of an existing variable. It is similar to a pointer in C with some differences as it is declared with & Operator.



Best WordPress Hosting


Share:

SSL for business, from $12.88


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments