| Other C++ General Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| How to avoid a class from instantiation? | Symphony | 5 |
| What are the differences between a struct and a class in
C++? | Wipro | 4 |
| Given a simple program designed to take inputs of integers
from 1-1000 and to output the factorial value of that
number, how would you test this program? You do not have
access to the code. Please be as specific as possible.
| Microsoft | 2 |
| Find the second maximum in an array?
| HCL | 2 |
| what is the order of initialization for data? | TCS | 4 |
| What is the difference between Pointer and a Reference?
When you would use them? | Wipro | 2 |
| What is difference between initialization and assignment? | HP | 4 |
| In a class only declaration of the function is there but
defintion is not there then what is that function?
| Hughes | 4 |
| What is the Difference between "vector" and "array"? | TCS | 6 |
| How do you know that your class needs a virtual destructor? | Lucent | 3 |
| whats the size of class EXP on 32 bit processor?
class EXP
{
char c1;
char c2;
int i1;
int i2;
char *ptr;
static int mem;
}; | Huawei | 4 |
| 1)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea += sizeof(int);
}
return 0;
}
2)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea ++;
}
return 0;
}
The output of this two programs will be different why?
| | 2 |
| What is Memory Alignment? | TCS | 1 |
| Can you explain the term "resource acquisition is
initialization?" | | 1 |
| How long does this loop run:
for(int x=0; x=3; x++)
a) Never
b) Three times
c) Forever
| Quark | 9 |
| 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 are inline functions? | Verizon | 2 |
| is throwing exception from a constructor not a good practice ? | Ericsson | 4 |
| What is Name Decoration? | Lucent | 2 |
| What is Object Oriented programming.what is the difference
between C++ and C? | Infosys | 5 |
| |
| For more C++ General Interview Questions Click Here |