HOME

YEAR N ORG

Wednesday, April 18, 2007

interview qns..on c,c++,gen

Over the past couple of years, I've interviewed a lot of folks for development positions - mostly C++ and COM on Windows. Some people are outstanding, some are truly horrible; but a large number of people seem bright, but just don't have the depth of knowledge that I think a professional C++ developer should have.
What follows is a list of questions that I typically ask interview candidates. No, I'm not going to give you the answers - that's up to you. Someday, you'll be sitting across from me or someone like me, and they'll ask you questions like these.
When that happens, resist the temptation to give a pat, memorized answer. You should be able to take any one of these questions, and talk about each one with an interviewer for at least five minutes or so. The type of candidate that really impresses me is not the one who can answer using the fewest words, it's the one that knows something well, and can explain it to me.

General Questions

These are questions I tend to ask at the beginning or at then end of an interview. There are no right or wrong answers - the intent is to find out more about a candidate, and to get them comfortable talking about themselves.
How did you get into computer science?
What kind of technical publications (print or online) do you read on a regular basis?
What was the last book you read (does not have to be job related!)
If you could recommend one resource (book, web site, etc.) to a new software developer just out of school, what would it be?
What was the most interesting project that you worked on?
What was the most challenging project that you worked on?
If you could have any job in the world, what would it be?

C++ Questions
What are the major differences between C and C++?
What are the differences between new and malloc?
What is the difference between delete and delete[]?
What are the differences between a struct in C and in C++?
What are the advantages/disadvantages of using #define?
What are the advantages/disadvantages of using inline and const?
What is the difference between a pointer and a reference?
When would you use a pointer? A reference?
What does it mean to take the address of a reference?
What does it mean to declare a function or variable as static?
What is the order of initalization for data?
What is name mangling/name decoration?
What kind of problems does name mangling cause?
How do you work around them?
What is a class?
What are the differences between a struct and a class in C++?
What is the difference between public, private, and protected access?
For class CFoo { }; what default methods will the compiler generate for you>?
How can you force the compiler to not generate them?
What is the purpose of a constructor? Destructor?
What is a constructor initializer list?
When must you use a constructor initializer list?
What is a:
Constructor?
Destructor?
Default constructor?
Copy constructor?
Conversion constructor?
What does it mean to declare a...
member function asvirtual?
member function asstatic?
member function asstatic?
member varible as static?
destructor as static?
Can you explain the term "resource acqusition is initialization?"
What is a "pure virtual" member function?
What is the difference between public, private, and protected inheritance?
What is virtual inheritance?
What is placement new?
What is the difference between operator new and the new operator?
What is exception handling?
Explain what happens when an exception is thrown in C++.
What happens if an exception is not caught?
What happens if an exception is throws from an object's constructor?
What happens if an exception is throws from an object's destructor?
What are the costs and benefits of using exceptions?
When would you choose to return an error code rather than throw an exception?
What is a template?
What is partial specialization or template specialization?
How can you force instantiation of a template?
What is an iterator?
What is an algorithm (in terms of the STL/C++ standard library)?
What is std::auto_ptr?
What is wrong with this statement? std::auto_ptr ptr(new char[10]);
It is possible to build a C++ compiler on top of a C compiler. How would you do this? (Note: I've only asked this question once; and yes, he understood that I was asking him how cfront was put together. We hired him.)/i>
Code Snippets
I like to put these up on a whiteboard, and ask questiosn about them.

What output does the following code generate? Why?
What output does it generate if you make A::Foo() a pure virtual function?
#include

class A {
public:
A() {
this->Foo();
}
virtual void Foo() {
cout << "A::Foo()" << endl;
}
};

class B : public A {
public:
B() {
this->Foo();
}
virtual void Foo() {
cout << "A::Foo()" << endl;
}
};

int main(int, char**)
{
B objectB;

return 0;
}


What output does this program generate as shown? Why?
#include

class A {
public:
A() {
cout << "A::A()" << endl;
}
~A() {
cout << "A::~A()" << endl; throw "A::exception";
}
};

class B {
public:
B() {
cout << "B::B()" << endl; throw "B::exception";
}
~B() {
cout << "B::~B()";
}
};

int main(int, char**) {
try {
cout << "Entering try...catch block" << endl;

A objectA;
B objectB;

cout << "Exiting try...catch block" << endl;
} catch (char* ex) {
cout << ex << endl;
}

return 0;
}


Misc. Questions

What's the difference between SQL, DDL, and DML?
What's a join? An inner join? An outer join?
Describe HTTP.
What's a design pattern?
Can you explain the singleton, vistor, facade, or handle class design pattern?
Additional Links
 HYPERLINK "http://www.softcorp.demon.co.uk/c++2.htm" Wanted: Senior C++ Programmer by Al Stevens
 HYPERLINK "http://www.ddj.com/articles/1998/9813/9813d/9813d.htm" Passing the C++ Test: Securing success in an interview by Al Stevens
 HYPERLINK "http://members.home.net/shimonp/Interview/interview_right.html" The IT Interview User Guide
 HYPERLINK "http://www.cpuniverse.com/jobs/c++.shtml" The C++ Interview
 HYPERLINK "http://www.4guysfromrolla.com/webtech/012700-1.shtml" Microsoft Interview Questions & Answers
Programming Interview Exposed by John Mongan and Noah Suojanen (ISBN 0471383562)
From  HYPERLINK "http://www.amazon.com/exec/obidos/ASIN/0471383562/qid=966272233/102-6880095-8004119" Amazon
From  HYPERLINK "http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0471383562&from=MJF138" Fatbrain

No comments:

Recent Comments