| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| int f() {
int I = 12;
int &r = I;
r += r / 4;
int *p = &r;
*p += r;
return I;
}
Referring to the sample code above, what is the return value
of the function "f()"?
a) 12
b) 15
c) 24
d) 17
e) 30
| Quark | 2 |
| In a class only declaration of the function is there but
defintion is not there then what is that function?
| Hughes | 4 |
| In C++ cout is:
a) object
b) class
c) something else | Lehman-Brothers | 10 |
| wrong statement about c++
a)code removably
b)encapsulation of data and code
c)program easy maintenance
d)program runs faster | | 8 |
| is throwing exception from a constructor not a good practice ? | Ericsson | 2 |
| What is the difference between operator new and the new
operator? | Wipro | 1 |
| In a class, there is a reference or pointer of an object of
another class embedded, and the memory is either allocated
or assigned to the new object created for this class. In
the constructor, parameters are passed to initialize the
data members and the embedded object reference to get
inialized. What measures or design change should be advised
for proper destruction and avioding memory leaks, getting
pointers dangling for the embedded object memory
allocation? Please suggest. | GE | 3 |
| How to avoid a class from instantiation? | Symphony | 4 |
| How can you quickly find the number of elements stored in a
a) static array b) dynamic array ? | Lucent | 3 |
| Which one of the following describes characteristics of
"protected" inheritance?
a) The base class has access only to the public or protected
members of the derived class.
b) The derived class has non-public, inheritable, access to
all but the private members of the base class.
c) The derived class has access to all members of the base
class.
d) The private members of the base class are visible within
the derived class.
e) Public members of the derived class are privately
accessible from the base class.
| Quark | 3 |
| How to construct virtual constructor | Symphony | 4 |
| Is there something that we can do in C and not in C++? | Patni | 4 |
| How do you link a C++ program to C functions?
| | 2 |
| How is an Abstract Base Class(ABC) related to an "Abstract
Data Type" (ADT) | | 2 |
| What is the difference between method and message? | HP | 2 |
| How to avoid changing constant values? | Symphony | 1 |
| Difference between delete and delete[]? | TCS | 2 |
| What will happen if when say delete this ? | | 3 |
| what is an array
| | 12 |
| What is conversion constructor? | TCS | 1 |
| |
| For more C++ General Interview Questions Click Here |