Você está na página 1de 4

1. What is C++?

C++ language was developed by Bjarne Stroustrup in AT&T Bell Labs which are an extension of C language. It is
an object oriented programming language which is used for developing commercial and enterprise applications.
Visual C++ of Microsoft became the best and perfect choice for the programmers and developers.


2. Mention the fundamental concepts of object oriented programming language?

It is mandatory to understand vital concepts which are highly used in the object oriented programming languages.
Includes:
Objects
Classes
Inheritance
Encapsulation and data abstraction
Polymorphism
Message passing
Dynamic binding

3. Define encapsulation?

Encapsulation is wrapping up of functions and data in a single unit. This single is nothing but a class. Information
about an object is hidden such as code and the internal data structure in encapsulation.

4. What is an inheritance?

Inheritance is deriving a new class from the old class and the old class is known as base class whereas new class is
known as derived class. The main usage of inheritance is reuse of the existing code than rewriting the code from
scratch when it is required. In this process, object o one class obtains properties of other class.

5. Define polymorphism?

Polymorphism is one name with different forms. In the program, it permits you to have more than one function with
same name. It helps in overloading so an operation is shown in different behaviors differently.

6. Define message passing?

A set of objects is present in an object oriented programs for communicating with each other. Specifying the name
of object, information to be sent and the function name is included in message passing.




7. Define tokens in C++?

In a program, the smallest individual units are known as tokens. The following are the tokens of C++ programming
language:
Identifiers
Strings
Constants
Keywords
Operators


8. What is a constructor?

The member function which has a same name of its class is known as a constructor. When an object of a class is
created then invoking of a constructor takes place. The name constructor is given because it constructs values of
data members of class.


9. Where do you use enumerated data type?

Enumerated data type is a user defined data type which is used to attach names to numbers to increase
unambiguousness of code. Lists of words are enumerated automatically by enum keyword by assigning then values
0, 1, 2, 3, etc.


10. Why the default constructor is used?

A default constructor is a constructor which does not accept any parameters is known as a default constructor.


11. Define destructor?

For an object class, a destructor is called when the object is out of the scope or it is deleted explicitly. As the name
implies, the destructor is used to destroy objects that are created by the constructors. The destructor is also a member
function like the constructor whose name is its class name but it is preceded by tilde.



12. Does variable declaration in C++ differ from C?

Yes. In the C language, variables are declared in the beginning of scope whereas in C++, anywhere in the scope
variables can be declared. Understanding is made easy to the programmer as variables are declared in the context of
usage.


13. Define a class?

A class is a template which contains data members and member functions.


14. Differentiate C and C++?

The main difference between C and C++ is C is a procedure oriented language whereas C++ is an objected oriented
programming language. C language is considered as a super set of C++. Function overloading, inheritance and
method overloading are not supported by C language whereas C++ supports them. In a C program, main function
need not return a value whereas it must return a value in C++.


15. Define a copy constructor?

The constructor which has the same name of a class and which is used to copy the objects deeply is known as a copy
constructor.
16. Define a scope resolution operator?

An identifier is referenced in the global scope which is hidden by other identifier with same name in local scope is
allowed by the scope resolution operator.




17. Distinguish object and instance?

Object is an instance of user-defined type. From one class, multiple objects can be instantiated whereas an instance
of a class is object.


18. Differentiate macro and inline?

A strict parameter type checking is followed by inline but it is not followed by macro.
Preprocessor is used to expand macros and the inline definitions may or may not be replaced by the compiler.


19. Define Multiple Inheritance?

The class which inherits or acquires properties from many classes then it is known as inheritance.



20. Define implicit conversion?

Automatic conversion is performed by C++ if the data type are mixed in the expression. Smaller type is changed to
wider type. Integer converting to float type is an example.

21. In C++, give the usage of virtual destructor?

If the object is destroyed then the destructor is called automatically. In C++, virtual destructor is mainly used to
avoid resource leaks by doing clean-up of an object.



22. In C++, what is a reference variable?

An alias is provided by a reference variable to a variable which is previously defined.


23. Describe virtual functions?

The virtual functions must belong to particular class.
They are not static members.
Object pointers are used to gain access these virtual functions.
A virtual function may be a friend of other class.


24. Mention inheritance advantages?

Time is saved in developing a program.
Code can be reused.


25. Define dynamic constructor?

While creating objects, memory is allocated using constructors. Objects are allocated memory at the construction
time which is known as dynamic construction of objects. Here, allocation of memory can be done using an operator
called new.

26. Why declaration is used?

Name is used from a namespace if it is declared.



27. Define conversion constructor?

The constructor which has a single parameter that is declared without using function specifier is known as a
conversion constructor. The converting constructors are used to convert from first parameter type to converting
constructors class type.


28. Define associative container?

Associative containers are specially designed to provide gain access to elements with keys. In general, the
associative containers are of four types, they are:
Map
Set
Multimap
Multiset


29. Give some pure object oriented languages?

Java
Smalltalk
Sather
Eiffel
The candidate who is looking for the interview questions on C++ is at the right place as this article has the exact
information to prepare for the interview. These interview questions are given appropriate and easy answers so that
the candidate can remember them easily. Generally, most of the people find difficulty in clearing the technical round
of an interview so they can face the interview easily after going through these

Você também pode gostar