C++ Interview Questions With Answer
1. Why Need C++ ?
—C++ is a very powerful language. Easily modifying and extending implementations of components without having to recode everything from scratch thanks to C++'s performance, it is often used to develop game engines, games, and desktop apps. Many types of app, video games are built with C++.
2. What is the difference between Object Oriented Vs Structured Programming?
|1||Function Oriented||Object Oriented|
|2||Procedure Abstraction||Procedure & Data abstraction|
|3||Does not support External Interface||Supports External Interface|
|4||Free flow of Data||Secured Data & not freely flows|
|5||Also called FOP||Also called OOP|
3. What is Object Oriented paradigm?
- − Software Evolution.
- − Evolution of Programming Paradigm.
- − Monolithic.
- − Procedure Oriented Programming.
- − Structured Oriented Programming.
- − Object Oriented Programming.
4. What is Object-Oriented Programming?
− Object-oriented programming is a standard or programming methodology that associates with custom data structures and a collection of operators & functions that act upon it.
Well suited for:
- − Building reusable software elements plus easily extendable libraries.
- − Easy modification and extending implementations of elements without need to recode everything from scratch.
- − Modeling the real life problem as close as likely to the users perspective.
- − Communicating easily with the computational situation.
5. What is a class?
Class is a collection of similar objects.Class is a template which reflects the entities attributes and actions. In programming language class is designing for an user-defined data type.
6. What is an object?
- − Objects is a fundamental building base.
- − Objects are the essential run-time entities in an object-oriented system..
- − All these objects are connected with the data and functions that define essential operations on that object.
- − Object is a real life existing entity.
- − Object is an Instance of a specific class.
7. What is encapsulation?
The method of binding the function and data that associates the data and the code which forms it into a single unit and keeps them secure from external interference and misuse.
8. What is data abstraction in c++?
In Object-oriented programming, data Abstraction is a clear representation of an object which includes only features one is interested in whereas hides away the unnecessary functions. Data abstraction becomes an user-defined type or a abstract data type (ADT).
9. What is inheritance?
- − Inheritance is the method of accessing the base class characteristics inside the derived class.
- − Inheritance is the method by that one object can access the characteristics of different object.
- − Inheritance gives us the reusability moreover extensibility of the code.
10. List the types of inheritance supported in c++?
- − Single Inheritance
- − Multiple Inheritance.
- − Hierarchical Inheritance
- − Multilevel Inheritance
- − Hybrid Inheritance (also known as Virtual Inheritance)
11. What is polymorphism in object oriented programming?
- − In short, Polymorphism is the ability to call various functions by only using one type of function call.
- − Polymorphism implies that the same information can exist in two forms.
12. What is Dynamic Binding?
Dynamic Binding is the method of combining of the code linked with a system call at the run-time.
13. What is Message Passing?
The message passing is a method of requesting an operation on an object. In acknowledgment of a message, the similar method is executed in the object.
14. What is Literals in C++?
A series of characters, that represents constant values that are stored in variables.
C++ literals are:
- − Character literals are: ‘A’, ‘B’
- − Floating_point literals are: 4.67,3.14E-05
- − Integer literals are: 1,2,456,0xffff
- − String literals are: “ABC”, “TOTAL”
15. What is Modular Programming?
The Modular programming is the method of breaking a large program into tiny manageable tasks and designing them separately is known as Modular Programming or Divide¯&¯Conquer Technique.
16. What is Variable Scope in C++?
The scope of a variable is the piece of a program wherever the variable has the sense (where it exists). extensive
- − A local variable’s scope is limited over a function that declares that variable.
- − A global variable has the global (extensive) scope.
- − A block variable’s scope is limited over a block in which the variable is declared.
17. What is Storage class?
Each variable holds a storage class.
- − Determines the lifetime during that variable exists in memory
- − Some variables are created only once
- − In a program Global variables are created only once.
- − Some variables are created multiple times
- − Local variables are created every time a function is called.
18. What is Data Hiding?
Data hiding is a software development technique specifically used in object-oriented programming to the hiding of the implementation details of a class such a way that are hidden from the user.
- − Makes Maintenance of Application Easier
- − Improves the Understandability of the Application
- − Enhanced Security
19. What is constructor?
In class-based object-oriented programming, a constructor function is a special function that is a member of a class and has the same name as that class, used to create, and initialize objects of the class.
20. What are the types of constructor in c++?
- − Parameterized constructors
- − Overloaded constructors
- − Constructors with default argument
- − Copy constructors
- − Dynamic constructors
21. What is destructor in c++?
A destructor function is a special function that is a member of a class that used to destroy the objects.
- − Must be declared in public section.
- − Destructor does not have arguments = return type.
22. What is static data members in c++?
Static data members of a class are also known as class variables.
- − Because their content does not depend on any object.
- − They have only one unique value for all the objects of that same class.
23. What is Static Member Functions?
Member functions that are declared with static specifier.They can directly refer to static members of the class.
24. What is a friend function?
A friend function is a non-member function which can access the private members of a class.
25. What is a friend class?
Friend Class A friend class can be a friend of another class, allowing access to the protected and private members of the class in which is defined.
26. What is Dynamic Objects in C++?
Dynamic objects are objects that are created / Instantiated at the run-time by the class.
27. What is This Pointer?
this- pointer points to the current object and that used for invoked the function.
28. What is operator overloading?
C++ allow's to the compiler how to perform a particular operation when its corresponding operator is used on one or more variables.
- − Operator overloading is closely related to function overloading.
- − Allows the full integration of new class types into the programming environment .
29. What is virtual function?
In object-oriented programming, in languages such as C++, a virtual function or virtual methodA virtual function is a member function that is declared within a base class and redefined by a derived class.
30. What is a pure virtual function?
A pure virtual function or pure virtual method is a virtual function that has no definition within the base class.
31. What is an abstract class in C++?
A class that contains at least one pure virtual function then it is said to be an abstract class.
32. What is the difference between early binding and late binding in C++?
- − Early binding also called static binding as refers to events that occur at compile time.
- − Early binding occurs when all information needed to call a function is known at compile time.
- − Late binding refers to function calls that are not resolved until run time.
- − Late binding can make for somewhat slower execution times.
33. What is File Pointers?
- − Each file has two associated pointers
- − get pointer: to reads from file from given location
- − put pointer: to writes to file from given location
34. What is an exception handling?
Exception: An abnormal condition that arises in a code sequence at run time.
- − An exception is a run-time error.
- − Exception handling allows us to manage run-time errors in an orderly fashion.
© 2016-2019, Codeverb.com - All Rights Reserved