Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Search Your Question

Thursday, July 24, 2008

Yahoo Interview

1) There is a n x n grid of 1's and 0's. Find the i , where i is the row
containing all 1's and all 0's(except the intersection point). Should do
it in less than 25 comparisons
..
2) Use 2 stacks to implement a queue. Followed up with making the
access to the Data structure concurrently.

3) C++ question was good, implement a c++ class such that it allows us
to add data members at runtime.

4)Implement a transaction manager in a database server. The discussion
involved a lot of stuff about transaction logs.

5) How do you tune an application. Creating indexes.

6) Some SQL performance tuning questions on creating indexes.

7) can you write a foo() in c? If so how can u do it?

8) vector implementation questions.

9) Almost everyone asked about my language.(except ppl who attended my talk).

Yahoo Interview Questions

Yahoo Telephonic Round:

Design classes for the following problem. (C++)

A Customer Can have multiple bank accounts A Bank account can be owned by multiple customers When customer logs in he sees list of account, on clicking on an account he sees list of transactions.

Solution :

Customer class, Account class, Transaction class
Customer class contains an array of pointers to the account classes
Account class contains an array of pointers to its owner customer classes
Account class also contains an array of transactions associated to it.
Transaction class contains id or pointer the customer who did that transaction
In customer class write a function with prototype

for (i in Accounts )
{
cout << i.AccountName << endl;
}
cin >> id;
for(i in Accounts[id].transactions )
{
cout << i.TransDetails << endl;
}



Yahoo Interview Round 1:

1. How to call a C++ function which is compiled with C++ compiler in C code?

Solution: The C++ compiler must know that f(int,char,float) is to be called by a C compiler using the extern "C"construct:

The extern "C" line tells the compiler that the external information sent to the linker should use C calling conventions and name mangling (e.g., preceded by a single underscore). Since name overloading isn't supported by C, you can't make several overloaded functions simultaneously callable by a C program.

// This is C++ code
// Declare f(int,char,float) using extern "C":
extern "C" void f(int i, char c, float x);
...
// Define f(int,char,float) in some C++ module:
void f(int i, char c, float x)
{
.....
}



2. When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)
3. How do you initialize a static member of a class with return value of some function?

Solution :

Static data members are shared by all object instances of that class. Each class instance sees and has access to the same static data. The static data is not part of the class object but is made available by the compiler whenever an object of that class comes into scope. Static data members, therefore, behave as global variables for a class. One of the trickiest ramifications of using a static data member in a class is that it must be initialized, just once, outside the class definition, in the source file. This is due to the fact a header file is typically seen multiple times by the compiler. If the compiler encountered the initialization of a variable multiple times it would be very difficult to ensure that variables were properly initialized. Hence, exactly one initialization of a static is allowed in the entire program.

Consider the following class, A, with a static data member, _id:


//File: a.h
class A
{
public:
A();
int _id;
};

The initialization of a static member is done similarly to the way global variables are initialized at file scope, except that the class scope operator must be used. Typically, the definition is placed at the top of the class source file:

// File: a.cc
int A::_id;

Because no explicit initial value was specified, the compiler will implicitly initialize _id to zero. An explicit initialization can also be specified:


// File: a.cc
int A::_id = 999;


In fact, C++ even allows arbitrary expressions to be used in initializers:

// File: a.cc
int A::_id = GetId();

4. How can one application use same API provided by different vendors at the same time?
5. If you are given the name of the function at run time how will you invoke the function?

Solution :
* Compile your program with --export-dynamic on the gcc command line
* Link with -ldl (dynamic library handling, needed for dlopen and dlsym
* Call dlopen() with a null parameter, meaning you aren't loading symbols from a file but from the current executable
* Call dlsym() with the name of the function you'll be calling. Note that C++ modifies function names, so If you're trying this with C++, you'd have to either declare this function as extern "C", or figure out what name the function has after compiling. (On unix, you could run nm -s on the object file for this).
* If dlsym() returns non-null, use the returned value as a function pointer to invoke your function.

Yahoo Interview Round 2:

1. When will you use shell script/Perl ahead of C/C++?
2. How does yahoo handles billions of requests, does it create a thread per request or a process?
3. How does HTTP works?

Solution :HTTP Is a request-response protocol.

For example, a Web browser initiates a request to a server, typically by opening a TCP/IP connection. The request itself comprises o a request line, o a set of request headers, and o an entity. The server sends a response that comprises o a status line, o a set of response headers, and o an entity. The entity in the request or response can be thought of simply as the payload, which may be binary data. The other items are readable ASCII characters. When the response has been completed, either the browser or the server may terminate the TCP/IP connection, or the browser can send another request.

4. How to count number of unique music titles downloaded from a log file which contains an entry of all music title downloaded?
5. What is the difference between COM and CORBA?

Solution :COM is linked to Microsoft and CORBA to UNIX,Moreover, COM objects require installation on the machine from where it is being used .CORBA is ORB (Object request broker) , and also its a specification owned by OMG, which is open. Not owned by a company. So we cannot say that it only belongs to Unix. Corba servers can run on windows NT, and CORBA clients can run on Unix.

6. What is web service?

Solution :Web Service is defined as "a software system designed to support interoperable Machine to Machine interaction over a network." Web services are frequently just Web APIs that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services.

I got only these two Rounds as of now, if I get any more I will post them here. If you have attended yahoo interview please share your experience and questions with us. You can mail them at kchaitanyya@gmail.com or you can comment here.Solutions for rest of questions will be provided later.if you know any of the questions which are unsolved please comment the solution. we will include.

Yahoo Interview Questions-1

# A modified insertion sort uses binary search to find the position of insertion. What would be the improvement in order realized?

# class a{};
main()
{
count <<>
}
What is the output?

# The linked list size is unknown and it is very large. Find out the N th element from the back end.

# What happens in the following code?
char x[10],y[10];
x=y;

# Design a stack which supports push, pop, min and max operations in O(1).

# Design an NFA to accept a string of 0s and 1s.

# Given a balanced BST tree, write a function to replace the root with a node that belongs to the original tree.

# Explain what this function does


char *mystrcpy(char *s)
{
char des=char [MAXLEN];
char * t=des;
while(*s)
{
*++t=*++s;
}
return t;
}



# Given that you have a server hit by around 400 million users, and you have log files that contain the user ids of all of them. How do you find the frequency of login of each user. (The log files are very huge!!)

# Explain Polymorphism, Encapsulation, Inheritance, operator overloading?

Yahoo Interview Questions-2


# Design a data structure such that given a stream of numbers, you can find the maximum of the numbers at any point and also all the numbers.


# Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions.

# Find the common ancestor of two given nodes in a binary tree, how do you exploit the properties of a given BST for the same problem.

# Given a function getsort(data),that sorts the data given. The function sorts in place and does not use any extra memory. How do you validate the function with respect to 1)it sorts 2) it does not use extra memory

# Explain the Traveling Salesman problem? What is an NP-complete problem? What is the Hamiltonian cycle problem?

# Find out the least common ancestor in a binary tree.

Visual Basic Interview Questions -7

91. What is Dataware Control?

Any control bound to Data Control.
Ex:- Textbox, Check Box, Picture Box, Image Control, Label, List box, Combo Box, DB Combo,

92. What is the default model of the form? And what is it number?


93. Why we need OLE-Automation? Advantages?


94. What methods are used for DBGrid in unbound mode?

AddData, EditData, Readdata, WriteData.

95. What is ADO? What are its objects ?

ActiveX Data Object. ADO can access data from both flat files as well as the databases. I.e., It is encapsulation of DAO, RDO, and OLE that is why we call it as OLE-DB Technology. Objects are Connection, Record Set, Command, Parameter, field, Error, Property.

96. What is the max size allowed for Max Text box length.

32,000

97. Record set types and Number available in VB?

3.
1- Dynaset, 0 Table, 2 Snap Shot.

98. What is the max size allowed for Max Control Names length?

255.

99. How many procedures are in VB?

2.
function and sub procedures

100. What is the max size allowed for Max label caption length.?

2,048

101. what will be the result for 15/4 and 154 ?

15/4 = 3.75 and 154 = 3

102. What is the max size allowed for Msgbox Prompt and Input Box?

1024

103. Calling Stored Procedures in VB?

1. Calling Simply the Procedure with out Arguments "Call ProcedureName}"
2. If it is with Arguments Means then
Declare the Query Def qy
Set Qy as New Query def
Qy.SQL = "{Call ProcedureName(?

104. DSN Less Connection?

"Server=Oracle; Driver={Microsoft ODBC for Oracle};"

105. Visual Basic Interview Questions only

1. 3 main differences between flexgrid control and dbgrid control
2. ActiveX and Types of ActiveX Components in VB
3. Advantage of ActiveX Dll over Active Exe
4. Advantages of disconnected recordsets
5. Benefit of wrapping database calls into MTS transactions
6. Benefits of using MTS
7. Can database schema be changed with DAO, RDO or ADO?
8. Can you create a tabletype of recordset in Jet - connected ODBC database engine?
9. Constructors and distructors
10. Controls which do not have events
11. Default property of datacontrol
12. Define the scope of Public, Private, Friend procedures?
13. Describe Database Connection pooling relative to MTS
14. Describe: In of Process vs. Out of Process component. Which is faster?
15. Difference between a function and a subroutine, Dynaset and Snapshot,early and late binding, image and picture controls,Linked Object and Embedded Object,listbox and combo box,Listindex and Tab index,modal and moduless window, Object and Class,Query unload and unload in form, Declaration and Instantiation an object?
16. Draw and explain Sequence Modal of DAO
17. How can objects on different threads communicate with one another?
18. How can you force new objects to be created on new threads?
19. How does a DCOM component know where to instantiate itself?
20. How to register a component?
21. How to set a shortcut key for label?
22. Kind of components can be used as DCOM servers
23. Name of the control used to call a windows application
24. Name the four different cursor and locking types in ADO and describe them briefly
25. Need of zorder method, no of controls in form, Property used to add a menus at runtime, Property used to count number of items in a combobox,resize a label control according to your caption.
26. Return value of callback function, The need of tabindex property
27. Thread pool and management of threads within a thread pool
28. To set the command button for ESC, Which property needs to be changed?
29. Type Library and what is it's purpose?
30. Types of system controls, container objects, combo box
31. Under the ADO Command Object, what collection is responsible for input to stored procedures?
32. VB and Object Oriented Programming
33. What are the ADO objects? Explain them.
34. What are the different compatibility types when we create a COM component?
35. What do ByVal and ByRef mean and which is the default?
36. What does Option Explicit refer to?
37. What does the Implements statement do?
38. What is OLE and DDE? Explain.
39. What is the difference between Msgbox Statement and MsgboxQ function?
40. What keyword is associated with raising system level events in VB?
41. What methods are called from the ObjectContext object to inform MTS that the transaction was successful or unsuccessful?
42. What types of data access have you used.
43. What was introduced to Visual Basic to allow the use of Callback Functions?
44. Which controls can not be placed in MDI?
45. Which controls have refresh method, clear method
46. Which Property is used to compress a image in image control?
47. Which property of menu cannot be set at run time?
48. Which property of textbox cannot be changed at runtime and What's the maximum size of a textbox?
49. Which tool is used to configure the port range and protocols for DCOM communications?
50. What is Dll?
51. Question How many images can be placed in the image list?
52. What is the result of Null * Any value = 0 (Zero)?


Visual Basic Interview Questions -6

76. What are the type of validation available in VB?

Field, Form

77. How to trap Data Base Error?

Dim x as RDOError
X(0).Des
X(1).Number

Setting the Cursors.
Default Cursor 0
ODBC Cursor (Client side) 1
ServerSide Cursors (More Network traffic) - 2

78. How to declare Dll Procedure?

Declare function "" lib ""
Alias "" (Arg, ..) as Return type.

79. Referential Integrity (Take care By jet database Engine). Cascade Delete, Cascade Update is done setting property of Attributes.?

DbRelationDeleteCascade, DbRelationUpdateCascade.

80. How to increase the Date corresponding with month,date,year?

DateSerial(year(Now),Month(Now)+1,1)
Hour, min, sec, month, year, DateSerial, dateadd, datediff, weekday, datevalue, timeserial,timevalue.

81. Name some date function?

Dateadd(), Datediff(), Datepart(), Cdate()

82. What is difference between datagrid and flexgrid?

Datagrid Editable. Flexigrid Non-Editable. (Generally used for Read only purpose.)

83. What are two validate with Data Control?

Data_Validate, Data_Error.

84. To connect the Data Control with Back end What are all the properties to be set?

Data source Name, Record Source Name

85. What are the Technologies for Accessing Database from Visual Basic?set?

DAO, Data Control, RDO, ODBCDIRECT, ADO, ODBC API , 0040.

86. What is the diff between the Create Object and Get object?

Create Object - To create an instance of an object.
Get Object To get the reference to an existing object.

87. What is Mask Edit and why it is used?

Control. Restricted data input as well as formatted data output.

88. What is RdExecDirect?

Bypasses the Creation of a stored procedure to execute the query. Does not apply to Oracle.

89. Different type of Passing Value?

By value, By ref, Optional, Param Array. Note:- Optional keyword cannot be used while declaring arguments for a function using param array.

90. What are types of binding?

Assigning variable with defined memory space.
Late Binding - Memory size is allotted in later stage.
Ex:- Dim x as object
Early Binding - Memory size is allotted while declaring itself. New Key word is important.
Ex:- Dim x as New Object

Visual Basic Interview Questions -5

61. What is keyword used to compare to objects?

ISOperator Returns Boolean.

62. Suppose from form1 to form2 object property settings will arise to ?

Invalid procedure call or argument (Run time error 5)

63. What is the return type of Instr and Strcmp?

Instr integer (Numeric position)
Strcmp - integer ( if both the string are equal they result = 0)
Strcmp (Str1, Str2, Comparetype)
Comparing mode = 0 Binary Comparing
1 Textual Comparing

64. What is Implicit?

Instance of specific copy of a class with its own settings for the properties defined in that class.
Note: The implicitly defined variable is never equal to nothing.

65. What is Inprocess and Out of Process?

Inprocess It will run with in the memory. ( Local Machine). Out of Process It will run out of the memory Normally in the server side.

66. Where will we give the option explicit keyword and for what?

In the general declarations section. To trap undeclared variables.

67. How can we call Stored procedure of Back End in RDO and ADO ?

In RDO We can call using RDO Query Objects.
In ADO We can call using Command Objects.

68. What is Static Cursor?

In ADO Snap Shot is called so.

69. How to check the condition in Msgbox?

If(Msgbox("Do you want to delete this Record",VbYesNo)=VbYes)Then End if

70. What is control array and how many we can have it with in the form?

Group of control share the same name. Max 32, 767.

71. What is diff between the Generic Variable and Specific Variable?

Generic Variable:
Create Object Ex:-Ole-Automation . No need refer the object library.
Specific Variable:
Binding Procedure Early and Late Binding ( Can be Remove from the Memory).

72. What is the diff. Between function and sub procedures?

Function will return value but a sub procedure wont return values

73. What is the max size allowed for Extension in Visual Basic?

Frm, bas, cls, res, vbx, ocx, frx, vbp, exe

74. What is FireHouse Cursors?

Forward Only Some time Updateable

75. With in the form we want to check all the text box control are typed or not? How?

For each currentcontrol in controls
if typeof currentcontrol is TextBox then
end if
next


courtesy:DEVFYI - Developer Resource - FYI