C++ Important Questions
- Can we generate a C++ source code from the binary file?
- What are inline functions?
- What is “strstream” ?
-
What is encapsulation??
Containing and hiding information about an object, such as
internal data structures and code. Encapsulation isolates the
internal complexity of an object’s operation from the rest of
the application. For example, a client component asking for net
revenue from a business object need not know the data’s origin.
What is inheritance?
Inheritance allows one class to reuse the state and behavior
of another class. The derived class inherits the properties and
method implementations of the base class and extends it by
overriding methods and adding additional properties and methods.
What is Polymorphism??
Polymorphism allows a client to treat different objects in
the same way even if they were created from different classes
and exhibit different behaviors. You can use implementation
inheritance to achieve polymorphism in languages such as C++ and
Java. Base class object’s pointer can invoke methods in derived
class objects. You can also achieve polymorphism in C++ by
function overloading and operator overloading.
What is constructor or ctor?
Constructor creates an object and initializes it. It also
creates vtable for virtual functions. It is different from other
methods in a class.What is destructor?
Destructor usually deletes any extra resources allocated by
the object.
What is default constructor?
Constructor with no arguments or all the arguments has
default values.
What is copy constructor?
Constructor which initializes the it’s object member
variables ( by shallow copying) with another object of the same
class. If you don’t implement one in your class then compiler
implements one for you.for example:
Boo Obj1(10); // calling Boo constructor
Boo Obj2(Obj1); // calling boo copy constructor
Boo Obj2 = Obj1;// calling boo copy constructor
When are copy constructors called?
Copy constructors are called in following cases:a) when a function returns an object of that class by value
b) when the object of that class is passed by value as an
argument to a function
c) when you construct an object based on another object of the
same class
d) When compiler generates a temporary object
What is assignment operator?
Default assignment operator handles assigning one object to
another of the same class. Member to member copy (shallow copy)What are all the implicit member functions of the class? Or
what are all the functions which compiler implements for us if
we don’t define one.??
default ctor
copy ctor
assignment operator
default destructor
address operatorWhat is conversion constructor?
constructor with a single argument makes that constructor as
conversion ctor and it can be used for type conversion.
for example:
class Boo
{
public:Boo( int i );
};
Boo BooObject = 10 ; // assigning int 10 Boo object
What is conversion operator??
class can have a public method for specific data type
conversions.
for example:class Boo { double value; public: Boo(int i ) operator double() { return value; } }; Boo BooObject; double i = BooObject; // assigning object to variable i of type double. now conversion operator gets called to assign the value.
- Explain “passing by value”, “passing by pointer” and “passing by reference”
- Have you heard of “mutable” keyword?
- What is a “RTTI”?
- What is Memory Alignment?
- Why preincrement operator is faster than postincrement?
- What are the techniques you use for debugging?
- How to reduce a final size of executable?
- Give 2 examples of a code optimization.
- Is there something that I can do in C and not in C++?
- What is the difference between “calloc” and “malloc”?
- What will happen if I allocate memory using “new” and free it using “free” or allocate sing “calloc” and free it using “delete”?
- Difference between “printf” and “sprintf”.
- What is “map” in STL?
- When shall I use Multiple Inheritance?
- Explain working of printf.
- Talk sometiming about profiling?
- How many lines of code you have written for a single program?
- How to write Multithreaded applications using C++?
- Write any small program that will compile in “C” but not in “C++”
- What is the output of printf(”%d”)
- What will happen if I say delete this
- Difference between “C structure” and “C++ structure”.
- Diffrence between a “assignment operator” and a “copy constructor”
- What is the difference between “overloading” and “overridding”?
- Explain the need for “Virtual Destructor”.
- Can we have “Virtual Constructors”?
- What are the different types of polymorphism?
- What are Virtual Functions? How to implement virtual functions in “C”
- What are the different types of Storage classes?
- What is Namespace?
- What are the types of STL containers?.
- Difference between “vector” and “array”?
- How to write a program such that it will delete itself after exectution?
not bad but I think programs are in java language not c++
thanks a lot itz very useful
Usefull…..I was expecting answer from Q.no 5 -37
very useful questions
this questions is very helpful
I WANT TO C++ IMPORTANT QUESTIONS PLEASE
8. What is Memory Alignment?
9. Why preincrement operator is faster than postincrement?
10. What are the techniques you use for debugging?
11. How to reduce a final size of executable?
12. Give 2 examples of a code optimization.
13. Is there something that I can do in C and not in C++?
14. What is the difference between “calloc” and “malloc”?
15. What will happen if I allocate memory using “new” and free it using “free” or allocate sing “calloc” and free it using “delete”?
16. Difference between “printf” and “sprintf”.
17. What is “map” in STL?
18. When shall I use Multiple Inheritance?
19. Explain working of printf.
20. Talk sometiming about profiling?
21. How many lines of code you have written for a single program?
22. How to write Multithreaded applications using C++?
23. Write any small program that will compile in “C” but not in “C++”
24. What is the output of printf(”%d”)
25. What will happen if I say delete this
26. Difference between “C structure” and “C++ structure”.
27. Diffrence between a “assignment operator” and a “copy constructor”
28. What is the difference between “overloading” and “overridding”?
29. Explain the need for “Virtual Destructor”.
30. Can we have “Virtual Constructors”?
31. What are the different types of polymorphism?
32. What are Virtual Functions? How to implement virtual functions in “C”
33. What are the different types of Storage classes?
34. What is Namespace?
35. What are the types of STL containers?.
36. Difference between “vector” and “array”?
37. How to write a program such that it will delete itself after exectution?
Post to Twitter
this is very useful but i want to know the answer of cpp.
very useful and helping to more about c++ language.
i want to know the answer of the aove question
Very usefull thanks
it is so good but give us ans of all question
thanks for help me.
i want to know the answers of c++
Not bad….