Sei sulla pagina 1di 4

Q3: What are the different features of c++?

Ans: Following are the different features of the Classes in C++,

 Operators and function overloading


 Free storage management
 Constant types
 References
 Inline function
 Virtual function
 Templates
 Exception handling

Q4: Explain constructor?


Ans: Constructors is a member function having the same name as that of its class and is
executed automatically when the class is instantiated(object is created).

Q5: What are the various Arithmetic Operators in C++?

Answer: C++ supports the following arithmetic operators:

 + addition
 – subtraction
 * multiplication
 / division
 % module

What do you mean by ‘void’ return type?

Answer: All functions should return a value as per the general syntax.

However, in case, if we don't want a function to return any value, we use “void” to indicate
that. This means that we use “void” to indicate that the function has no return value or it
returns “void”.

Example:

1 void myfunc()
2{
3 Cout<<”Hello,This is my function!!”;
4}
5 int main()
6{
7 myfunc();
8 return 0;
9}

What's the order in which the objects in an array are destructed?

Answer: Objects in an array are destructed in the reverse order of construction: First
constructed, last destructed.
Q5: What is a function?
Ans: A function is a block of code which executes the statements when we call it.
It consists of three entities:
1) the function name.this is simply a unique identifier.
2) The function parameters.this is a set of zero or more typed identifier.
3) The function return type this specifies the type of value function returns.

Q6: Explain Inline function?


Ans: Inline function are those function whose function body is inserted in place of the
function call.

Q7: What is function overloading?


Ans: function polymorphism for function overloading is a concept that allows multiple
function to share the same name with different arguments type assigning one or more
function function body to the same name is known as function overloading.

Q8: What is implicit and explicit type conversion?


Ans: In implicit casting in c++ compile automatically handle the type conversion.the final
result expressed in the highest precision possible.

Explicit: the conversion of data type of two operands is not automatic but forced.we can force
an expression to be a specific type by using a cast.

Q9: What is inheritance in C++ and name the different types of inheritance?
Ans: it is a technique of organizing information in a hierarchy form. It is like a child
inheriting the features of its parent.
The class which we are inheriting from is called as the base class and the class which inherits
called as derived class.

Different types of inheritance are as follows-:


1) single level
2) Multi-level
3) Multiple
4) Hierarchical(hybrid)
5) multipath

Q10: What is friend function?


Ans: A friend function is a function which is use to access the private data member of
different class.

Questions and Answers

1. Why is C++ called object oriented programming/OOP language?

Ans . C++ is called object oriented programming (OOP) language because C++
language views a problem in terms of objects involved rather than the procedure
for doing it.

2. Differentiate between C and C++?


3. Differentiate between C++ and JAVA?
4. What is encapsulation?
5. What is a constructor?
6. What is overloaded constructor?
7. What is a destructor?
8. Can a destructor be overloaded?
9. What is a copy constructor?
10. What is shallow copy?
11. What is deep copy constructor?
12. Differentiate between deep copy constructor and shallow copy constructor?
13. What is the design of singleton class?
14. What is the default access modifier for class members and member
functions in a class?
15. What is the difference between a C structure and a C++ class?
16. What is the default access modifier for structure members and member
functions in a structure?
17. What is abstraction or data hiding?
18. What is THIS pointer?
19. What is a static function?
20. Why THIS pointer will not be created for a static function?
21. What is scope resolution operator?
22. What is an inline function in C++?
23. What is the difference between a private member and a protected
member?
24. What is a const function?
25. What is polymorphism?
26. What is operator overloading?
27. What is function overloading?
28. What is overriding?
29. How can I distinguish between prefix increment and postfix increment?
30. What is a friend class?
31. What is a friend function?
32. What is the size of a class having one or more virtual functions?
33. What is a virtual pointer or vfptr and virtual function table vftable? Explain
with diagram and example.
34. How does virtual function work? Understanding vfptr and vftable using C.
35. What is early binding and late binding?
36. What is inheritance?
37. Can a virtual function call from a constructor/destructor work properly?
38. What is a virtual destructor and its utility?
39. What is a virtual base class?
40. How can I overload global << and >> operators to work with
cin,cout,cerr etc?
41. What is an exception?
42. What is stack unwinding operation in exception handling?
43. How is exception handling done in C++?
44. Can you write a try-catch block that will catch all type of exceptions?
45. What is namespace?
46. How can I change a member variable within a const function?
47. What is mutable keyword and how is it used?
48. What does the keyword 'explicit' do? Why is it used?
49. How a function pointer may be used to access a member function?
50. What is object slicing?
51. What is ctor and what is the sequence of constructor calls?
52. What is dtor and what is the sequence of destructor calls?
53. Why is virtual destructor important in inheritance?
54. How can I print the type name of a variable?
55. What is dynamic casting?
56. What is static casting?
57. What is the difference between dynamic and static casting?
58. What is const casting?
59. What is reinterpret casting?
60. What is the difference between static casting and reinterpret casting?
61. What is template class?
62. How does template differ from macro?

Potrebbero piacerti anche