| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| What is a constructor initializer list and when we use
constructor initializer list?
| TCS | 2 |
| class Foo {
int x;
public:
Foo(int I);
};
If a class does not have a copy constructor explicitly
defined one will be implicitly defined for it. Referring to
the sample code above, which one of the following
declarations is the implicitly created copy constructor?
a) Foo(Foo *f);
b) Foo(Foo &f);
c) Foo(const Foo *f);
d) Foo(const Foo &f);
e) Foo(int);
| Quark | 3 |
| What are the basics of classifying different storage types,
why? | Symphony | 1 |
| How to write Multithreaded applications using C++? | Honeywell | 1 |
| How many bit combinations are there in a byte? | Intel | 7 |
| class Foo {
const int x;
protected:
Foo(int f);
~Foo();
};
Foo f;
Referring to the sample code above, why will the class
declaration not compile?
a) The variable x is const.
b) The destructor is protected.
c) The destructor is not public.
d) The constructor is protected.
e) There is no default constructor.
| Quark | 4 |
| What are the advantages and disadvantages of using inline
and const? | TCS | 1 |
| In C++ cout is:
a) object
b) class
c) something else | Lehman-Brothers | 10 |
| What is Memory Alignment? | TCS | 1 |
| what is data Abstraction? and give example | TCS | 13 |
| Find out the bug in this code,because of that this code
will not compile.......
#include <iostream>
#include <new>
#include <cstring>
using namespace std;
class balance {
double cur_bal;
char name[80];
public:
balance(double n, char *s) {
cur_bal = n;
strcpy(name, s);
}
~balance() {
cout << "Destructing ";
cout << name << "\n";
}
void set(double n, char *s) {
cur_bal = n;
strcpy(name, s);
}
void get_bal(double &n, char *s) {
n = cur_bal;
strcpy(s, name);
}
};
int main()
{
balance *p;
char s[80];
double n;
int i;
try {
p = new balance [3]; // allocate entire array
} catch (bad_alloc xa) {
cout << "Allocation Failure\n";
return 1;
} | | 2 |
| what is meaning of isa and hsa | | 1 |
| class HasStatic {
static int I;
};
Referring to the sample code above, what is the appropriate
method of defining the member variable "I", and assigning it
the value 10, outside of the class declaration?
a) HasStatic I = 10;
b) int static I = 10;
c) static I(10);
d) static I = 10;
e) int HasStatic::I = 10;
| Quark | 1 |
| Explain working of printf? | | 3 |
| what is the behaviour of C and C++ compiler for the below
statements.
int *p;
p = malloc(100);
Is the behaviour same ? or different ? | | 1 |
| When volatile can be used? | Symphony | 2 |
| Explain the difference between 'operator new' and the 'new'
operator? | Lucent | 1 |
| How is an Abstract Base Class(ABC) related to an "Abstract
Data Type" (ADT) | | 2 |
| What is the output of printf("%d")? | HCL | 25 |
| is throwing exception from a constructor not a good practice ? | Ericsson | 4 |
| |
| For more C++ General Interview Questions Click Here |