Sample Questions and Answers of Yahoo

Jan 7 • General, Resources • 1359 Views • 1 Comment on Sample Questions and Answers of Yahoo

Sample Questions and Answers of Yahoo :1) Just use a stack to store the values of the node to be printed as well as its children. Store some meta data to indicate a node which has to be just printed. Hence after evaluating the left and right children of a node colour the node black. And after printing the node pop it off the stack.

ans:

 void f(NODE* r)

{

(NODE*)[] visited;

stack;

stack.push(r);
visited.Add(r);

while(!stack.empty)
{
NODE* n=stack.pop();
if(visited.Contain(n))
{
print(n); 
}
else
{
if(!n->left && !n->right)
print(n);
else
visited.Add(n);
stack.push(n);
stack.push(n->right);
stack.push(n->left);
}
}
}

 

2) What is the difference between Serializable and Externalizable interfaces?

ans; Serializable and Externalizable both are used to persist the state of object into a file or byte stream.serializable is marker interface having no methods in it.while Externalizable have two methods readExternal(),writeExternal() to control the processing of seriliazation.externazable extends serializable interface.

3) On which layer of the OSI model does JVM works? On which layer of the OSI model does Sockets work?

ans; JVM will work on the top layer (Application layer)
Sockets : transport layer

4) What is the best way to handle distributed databases and to merge their results ??

ans; many ways. best would be replication services in SQLServer. may be a different name in other RDBMSs. Also add logging table support when merging critical tables.

5)Just use a stack to store the values of the node to be printed as well as its children. Store some meta data to indicate a node which has to be just printed. Hence after evaluating the left and right children of a node colour the node black. And after printing the node pop it off the stack.

ans;

stack.push(r);
visited.Add(r);

while(!stack.empty)
{
NODE* n=stack.pop();
if(visited.Contain(n))
{
print(n); 
}
else
{
if(!n->left && !n->right)
print(n);
else
visited.Add(n);
stack.push(n);
stack.push(n->right);
stack.push(n->left);
}
}
}

 

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

One Response to Sample Questions and Answers of Yahoo

  1. Shilpa Ranjan says:

    Some of the important software questions and answers of yahoo. this can helpful go through the post !!!1

« »