If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Recent Yahoo Interview Questions - May be Helpful

Folks,

I am an experienced developer and happend to attend the interview at yahoo India development centre.

The pity part is interviewers are coming with print outs of programs written on paper. So, It is often possible you can easily overlook some of the things on the paper. But that is the fact and be prepared...

Here we go:

Question 1:
========

class A()
{
A() : { func(); }

virtual void func() { cout << "in A " << endl; }
}

class B()
{

B();

virtual void func() { cout << "in B" << endl; }

}

main()
{
B b;
}

Question: What will be printed();

Question 2: (is there any problems with following programs?)

NOTE:- there may be mistake in my typing, but you can assume
that functions are correct.

I think, since there is no implementation of the B constructor, that as written nothing would be printed (nothing calls either func method).

I'm not sure if there is a transcription error here, this resembles a classic interview question that usually relies on B being a child of A.Or maybe they want you to think that's what they're asking about.

Question 5:
===========

One guy asked me following question.

Can you implement garbage collector in C++ and how you do that?

It may be possible, but to be honest, if some body can do this, it would have
been already available. May that is the research they are doing.

Answer: I'm a developer. Give me enough time and of course I can. It would probably involve rewriting the compiler or mandatory inclusion of some library (or both), and would be non-standard, but I could do it. 8o)

Last edited by ajhampson; 04-27-2010 at 11:29 AM.
Reason: clarification

Smart pointers and the like put the burden on the programmer though. At that point, its not GC, its a style guideline that greatly reduces the chance for pointer goofs/leaks/etc. IE a programmer can grab the code, hack in an "int *fubar = new int[1000000]; fubar = 0;" and ruin everything with just 2 lines of code, and there is no way (in the raw language) to handle this sort of problem, whether its from legacy code, opensource, programmer @ 2am, or whatever reason that gets it into the code. Once the style is violated, and just one programmer drops the ball, the GC of the whole system is compromised.

I don't think GC can be added to the language by a user of the language in any reliable fashion (apart from writing a nonstandard compiler). Code can be written to handle memory safely (but you can do that with raw pointers too) and tools exist to warn programmers about potentially problematic code and all that, yes. But to enforce GC upon joe-freshman@college using the full (not reduced subset of) c++ language any way he wants to using standard compilers, it cannot be done.