Sierra Technical Interview Questions

1. What is the output of the following program?
const int size = 5;
void print(int *ptr)
{
cout«ptr[0];
}

void print(int ptr[size])
{
cout«ptr[0];
}

void main()
{
int a[size] = {1,2,3,4,5};
int *b = new int(size);
print(a);
print(b);
}

a) 5 b) 1 2 3 4 5 c) 1 d) Error

2. What is the output of the following program?

class some{
public:
~some()
{
cout«'some's destructor'«endl;
}
};

void main()
{
some s;
s.~some();
}

a) some's destructor
some's destructor
b) some destructor
some destructor
c) Error
d) None of the above

3. What is the output of the program?
class opOverload{
public:
bool operator==(opOverload temp);
};

bool opOverload::operator==(opOverload temp){
if(*this == temp ){
cout«'The both are same objects ';
return true;
}
else{
cout«'The both are different ';
return false;
}
}
void main(){
opOverload a1, a2;
a1= =a2;
}

a) The both are same objects
b) The both are different
c) Stack overflow error
d) None of the above

4. What is the output of the following program?
class complex{
double re;
double im;
public:
complex() : re(1),im(0.5) {}
bool operator==(complex &rhs);
operator int(){}
};

bool complex::operator == (complex &rhs){
if((this->re == rhs.re) && (this->im == rhs.im))
return true;
else
return false;
}

int main(){
complex c1;
cout« c1;
}

a) 0 b) 1 c) Error d) Garbage value

5. Write a program to show quick sort?
6. How to find a data in binary tree?
7. What is the Locale class?
8. What do you understand by implicit casting?
9. Is sizeof a keyword in java?

Shared by: Susant Kumar