I stumbled into this interesting link. This has the top 25 oddball interview questions of 2011:
http://www.glassdoor.com/blog/top-25-oddball-interview-questions-2011/?utm_source=newsletter&utm_medium=email&utm_content=news-jan12u-top25&utm_campaign=news-jan12u
More food for thought!
Puzzles for Dot net developers
This page will have collection of puzzles solved in C# programming language.
Tuesday, January 10, 2012
Friday, December 23, 2011
Puzzle questions series
Operating Systems:
1) How many server operating system installations have you completed on your own? How many machines have you built?
2) Have you ever written an OS build doc for other people to follow?
3) Where do operating systems record errors and informational messages?
4) What is an environment variable ? How would you display one?
5) Explain the significance of a path environment variable?
6) What is an ACL? How would you display or change one?
7) What is a PID number? How would you display one?
8) Which applications do you use to view a 2GB log file?
9) What are some common tools to parse text or locate a word of phrase in a file or data stream?
10) How would you register or un-register a DLL and why would you do this?
11) What is your preferred file compression tool ?
12) Name a Windows Resource Kit or Support Tools utility and describe how you used it to solve a problem.
13) Describe a shell script of batch file that you've written.
14) How do you redirect the results of a command to a file? How do you redirect it to be processed by another command? What are a program's three IO streams called?
15) Describe an administration, troubleshooting or utility script in a non-shell, non-compiled language that you have written?
16) What is the boot.ini/3GB switch?
17) What's the difference between working set, private bytes and virtual bytes?
18) How do you identify and troubleshoot memory leaks in Windows?
SQL and relational database management systems:
1) What is the standard SQL command to query data in a table or view ?
2) What are some common clauses in a SQL SELECT statement?
3) How would you use a subquery in a select statement ?
4) What is the SQL Command to change the values of one or more columns in a table row?
5) Give an example of using an aggregate function in a select statement.
6) What is a stored procedure that executes automatically based on changes to the database?
7) What are the native tools to query databases using Oracle and SQL Server 2000 ? Which other ones have you used?
8) What is the command in SQL*Plus to make it write the results of its console to a file? What is the operator character to tell it to open and SQL file and execute its contents?
9) What are some ways to export and import or backup and restore databases in Oracle and SQL Server?
10) How do Oracle and SQL Server record the changes in data that occur between backups?
11) For a full Oracle client, what is the name of the file that lists network information necessary to connect to various databases in the environment?
12) How did you configure a DSN in Windows?
13) Name the tracing utilities for Oracle and SQL Server.
Web Servers:
1) What is WebLogic Server?
2) Name some http servers and application servers.
3) What's the main configuration file for IIS 6 ?
4) Where are the IIS log files kept in IIS 6 ?
5) What is Microsoft .Net?
6) Which .Net perfmon counters have you used to solve a problem ?
7) What is garbage collection ?
Network:
1) What is a MAC address ?
2) What is a command line or shell tool to display or change the network settings for an operating system ?
3) What kind of device typically acts as the default gateway ?
4) Which IP protocol does ping use ?
5) What is a command line or shell tool to display the network hops between one system and another one ?
6) What are some methods an OS uses to resolve another computer's name to its IP address ? What's the name of a file that can be edited to set this on a client ?
7) What is an FQDN ?
8) What is a three-way handshake ?
9) What is a TCP reset ? What conditions would cause a reset ?
10) What is a utility program to list the open sockets on a system ? What helpful information would you get ? What is an example socket state ?
11) What are some common ftp commands you might use?
12) What is an secure alternative to telnet ?
13) Name some tools to capture network traffic. Describe a problem you solved using one.
14) When configuring an application to use an http proxy server, what are some of the settings you will need to make? Name some proxy server software.
Other:
1) Describe any work you've done with crawlers or spiders
2) Describe any work involving OS virtualization
3) Describe any work you've done with Microsoft Sharepoint, Documentum or Lotus Notes
4) Describe any work you've done with Active Directory, Other directory servers?
5) Describe any work you've done with Microsoft Exchange, Other email systems?
6) Describe any work you've done with Help Desk Ticket Management Systems
7) Describe any work you've done with production environment Change Control Management systems
8) QA and Testing experience
9) Project Management, Software development methodologies?
10) What Social networking tools? Ever written for a wiki?
1) How many server operating system installations have you completed on your own? How many machines have you built?
2) Have you ever written an OS build doc for other people to follow?
3) Where do operating systems record errors and informational messages?
4) What is an environment variable ? How would you display one?
5) Explain the significance of a path environment variable?
6) What is an ACL? How would you display or change one?
7) What is a PID number? How would you display one?
8) Which applications do you use to view a 2GB log file?
9) What are some common tools to parse text or locate a word of phrase in a file or data stream?
10) How would you register or un-register a DLL and why would you do this?
11) What is your preferred file compression tool ?
12) Name a Windows Resource Kit or Support Tools utility and describe how you used it to solve a problem.
13) Describe a shell script of batch file that you've written.
14) How do you redirect the results of a command to a file? How do you redirect it to be processed by another command? What are a program's three IO streams called?
15) Describe an administration, troubleshooting or utility script in a non-shell, non-compiled language that you have written?
16) What is the boot.ini/3GB switch?
17) What's the difference between working set, private bytes and virtual bytes?
18) How do you identify and troubleshoot memory leaks in Windows?
SQL and relational database management systems:
1) What is the standard SQL command to query data in a table or view ?
2) What are some common clauses in a SQL SELECT statement?
3) How would you use a subquery in a select statement ?
4) What is the SQL Command to change the values of one or more columns in a table row?
5) Give an example of using an aggregate function in a select statement.
6) What is a stored procedure that executes automatically based on changes to the database?
7) What are the native tools to query databases using Oracle and SQL Server 2000 ? Which other ones have you used?
8) What is the command in SQL*Plus to make it write the results of its console to a file? What is the operator character to tell it to open and SQL file and execute its contents?
9) What are some ways to export and import or backup and restore databases in Oracle and SQL Server?
10) How do Oracle and SQL Server record the changes in data that occur between backups?
11) For a full Oracle client, what is the name of the file that lists network information necessary to connect to various databases in the environment?
12) How did you configure a DSN in Windows?
13) Name the tracing utilities for Oracle and SQL Server.
Web Servers:
1) What is WebLogic Server?
2) Name some http servers and application servers.
3) What's the main configuration file for IIS 6 ?
4) Where are the IIS log files kept in IIS 6 ?
5) What is Microsoft .Net?
6) Which .Net perfmon counters have you used to solve a problem ?
7) What is garbage collection ?
Network:
1) What is a MAC address ?
2) What is a command line or shell tool to display or change the network settings for an operating system ?
3) What kind of device typically acts as the default gateway ?
4) Which IP protocol does ping use ?
5) What is a command line or shell tool to display the network hops between one system and another one ?
6) What are some methods an OS uses to resolve another computer's name to its IP address ? What's the name of a file that can be edited to set this on a client ?
7) What is an FQDN ?
8) What is a three-way handshake ?
9) What is a TCP reset ? What conditions would cause a reset ?
10) What is a utility program to list the open sockets on a system ? What helpful information would you get ? What is an example socket state ?
11) What are some common ftp commands you might use?
12) What is an secure alternative to telnet ?
13) Name some tools to capture network traffic. Describe a problem you solved using one.
14) When configuring an application to use an http proxy server, what are some of the settings you will need to make? Name some proxy server software.
Other:
1) Describe any work you've done with crawlers or spiders
2) Describe any work involving OS virtualization
3) Describe any work you've done with Microsoft Sharepoint, Documentum or Lotus Notes
4) Describe any work you've done with Active Directory, Other directory servers?
5) Describe any work you've done with Microsoft Exchange, Other email systems?
6) Describe any work you've done with Help Desk Ticket Management Systems
7) Describe any work you've done with production environment Change Control Management systems
8) QA and Testing experience
9) Project Management, Software development methodologies?
10) What Social networking tools? Ever written for a wiki?
Tuesday, August 23, 2011
C# code to Arrange array values Columnwise
Question :
Format any given string array "columnwise" into 3 compact html columns (notice the example output is ordered by column, not by row) last row is only row that can be short (i.e. have one or two empty cells, see example below)
sample test case (your solution should pass any test case) string[] testArray = { "item 1", "item 2", "item 3", "item 4", "item 5", "item 6", "item 7", "item 8", "item 9", "item 10", "item 11" };
write your code here to create your html output from testArray[] as a stringResponse.Write(@"<table>
<tr><td>item 1</td><td>item 5<td>item 9</td><td></td></tr>
<tr><td>item 2</td><td>item 6<td>item 10</td><td></td></tr>
<tr><td>item 3</td><td>item 7<td>item 11</td><td></td></tr>
<tr><td>item 4</td><td>item 8<td></td><td></td></tr>
</table>"); Answerusing System;
using System.Collections.Generic;
using System.Text;
/*
* step 1 : Store array in arraylist
* step 2 : Find out no of blank cells in table and assign blank value for those cells
* step 3 : Shuffle the array for matrix
* step 4 : Display in required formate
* */
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string[] testArray = { "item 1", "item 2", "item 3", "item 4", "item
5", "item 6", "item 7", "item 8", "item 9", "item 10", "item 11" };
int noOfColumns = 3;
StringBuilder sb = new StringBuilder();
System.Collections.ArrayList tlist = new System.Collections.ArrayList()// Calculate no blankcells
int blankArray = noOfColumns - (testArray.Length % noOfColumns);
//populate the arrayvalues in ArrayList with blankcells
for (int x = 0; x < testArray.Length + blankArray; x++)
{
if (testArray.Length > x)
{
tlist.Add(testArray[x]);
}
else
{
tlist.Add("");
}
}
//Shuffle the array for matrix
System.Collections.ArrayList list = new System.Collections.ArrayList()
for (int i = 0; i < tlist.Count / 3; i++)
{
list.Add(tlist[i].ToString());
list.Add(tlist[i + noOfColumns + 1].ToString());
list.Add(tlist[i + (noOfColumns + 1) * 2].ToString());
}
// Add HTML tags and display the array
sb.Append("<table>");
for (int j = 0; j < 12; j = j + 3)
{
sb.Append("<tr>");
sb.Append("<td>" + list[j].ToString() + "</td><td>" + list[j + 1].ToString() + "</td><td>" + list[j + 2].ToString() + "</td>");
sb.Append("</tr>");
}
sb.Append("</table>");
Console.WriteLine(sb.ToString(
Console.ReadLine();
}
}
}
C# code to find second largest Element in an array
Question : Write C# code to find second largset element in an Integer Array
Possible solutions
1. Store values in List and sort the list and find the 3rd element in the list
2.Use Hashtable
3.Use for loop
4.Use bubble sort or any other sorting algorithm and print 3rd element (Code snippet will be published later)
Use for loop
private static void getSecondLargest(int[] intArray)
{
int maxVal = 0;
int secondMax = 0;
for (int i = 0; i < intArray.Length; i++)
{
if (intArray[i] > maxVal)
{
secondMax = maxVal;
maxVal = intArray[i];
}
else if (intArray[i] > secondMax)
{
// Print Second Largest Value
secondMax = intArray[i];
}
}
Console.WriteLine("Second Largest Value : "+secondMax);
}
{
int maxVal = 0;
int secondMax = 0;
for (int i = 0; i < intArray.Length; i++)
{
if (intArray[i] > maxVal)
{
secondMax = maxVal;
maxVal = intArray[i];
}
else if (intArray[i] > secondMax)
{
// Print Second Largest Value
secondMax = intArray[i];
}
}
Console.WriteLine("Second Largest Value : "+secondMax);
}
C# code to find the min value in an array
Question: Write a method to find the min value in an array.
What an Interviewer is looking far?
Think about the test cases clearly
Example:
Your input array can be in any of the following format
int[] intArray = null;
int[] intArray = {};
int[] intArray = { 1, 2, 3, 4, 5 };
int[] intArray = { 1, 3, 5, 7, 9 };
int[] intArray = { -1, -2, -3, -4, -5 };
int[] intArray = { 1, 2, 3, 4, 5 };
int[] intArray = { 1, 3, 5, 7, 9 };
int[] intArray = { -1, -2, -3, -4, -5 };
int[] intArray = { -5, -2, 0, -4, 5 };
I can think about 20 different test case for this input array.
int[] intArray = { -1, -5, -3, -4, -2 };
I can think about 20 different test case for this input array.
Possible Solutions:
1. Use Hashtable
2 Take a[0] as pivot and using a for-loop traverse the array and find the min element
3. Use sorting algorithm- Eg bubble sort.
a[0] as pivot element and find a min value of an array
private static void getMinValue(int[] intArray) //throws Exception
{
if (intArray != null)
{
//throw new System.ArgumentNullException();// Exception("\n Invalid intArray as it is null");
Console.ReadLine();
}
else
{
throw new Exception("exception for null");
Console.WriteLine("I am in Null check else block");
}
if (intArray.Length == 0)
{
Console.WriteLine("There are no elements in the array");
Console.ReadLine();
}
else
{
int min = intArray[0];
for (int i = 0; i < intArray.Length; i++)
{
if (intArray[i] < min)
{
min = intArray[i];
}
}
Console.WriteLine("Min value in the array : " + min);
}
}
{
if (intArray != null)
{
//throw new System.ArgumentNullException();// Exception("\n Invalid intArray as it is null");
Console.ReadLine();
}
else
{
throw new Exception("exception for null");
Console.WriteLine("I am in Null check else block");
}
if (intArray.Length == 0)
{
Console.WriteLine("There are no elements in the array");
Console.ReadLine();
}
else
{
int min = intArray[0];
for (int i = 0; i < intArray.Length; i++)
{
if (intArray[i] < min)
{
min = intArray[i];
}
}
Console.WriteLine("Min value in the array : " + min);
}
}
C# code sample for Singleton design pattern to get a DB Connection
Question : Sample code for Singleton design pattern to get a connection to the DB
Singleton can be use where there is a need to create only one instance of a given class
Here are some common examples: File Handler, Print Spooler handler, Database connection, etc
Singleton class
public class ConnSingleton
{
private static ConnSingleton dbInstance;
private readonly SqlConnection conn = new SqlConnection(@"Data Source=127.0.0.1;database=soa;User id=sa1;Password=sa1;");
private ConnSingleton()
{
}
public static ConnSingleton getDbInstance()
{
if (dbInstance == null)
{
dbInstance = new ConnSingleton();
}
return dbInstance;
}
public SqlConnection GetDBConnection()
{
try
{
conn.Open();
Console.WriteLine("Connected");
}
catch (SqlException e)
{
Console.WriteLine("Not connected : "+e.ToString());
Console.ReadLine();
}
finally
{
Console.WriteLine("End..");
// Console.WriteLine("Not connected : " + e.ToString());
Console.ReadLine();
}
Console.ReadLine();
return con;
}
}
{
private static ConnSingleton dbInstance;
private readonly SqlConnection conn = new SqlConnection(@"Data Source=127.0.0.1;database=soa;User id=sa1;Password=sa1;");
private ConnSingleton()
{
}
public static ConnSingleton getDbInstance()
{
if (dbInstance == null)
{
dbInstance = new ConnSingleton();
}
return dbInstance;
}
public SqlConnection GetDBConnection()
{
try
{
conn.Open();
Console.WriteLine("Connected");
}
catch (SqlException e)
{
Console.WriteLine("Not connected : "+e.ToString());
Console.ReadLine();
}
finally
{
Console.WriteLine("End..");
// Console.WriteLine("Not connected : " + e.ToString());
Console.ReadLine();
}
Console.ReadLine();
return con;
}
}
Method to call from Main class:
public static void Main(string[] args)
{
ConnSingleton cs = ConnSingleton.getDbInstance();
cs.GetDBConnection();
Console.WriteLine("Connection Established");
}
{
ConnSingleton cs = ConnSingleton.getDbInstance();
cs.GetDBConnection();
Console.WriteLine("Connection Established");
}
C# code sample for reversing a string
Question: Write a method to reverse a string
Test case:
string s = "This is Test";
Output string s="tseT si sihT";
Possible solutions:
1. Use Array.Reverse
2. Use for loop and print reverse
3. Use stack
4. Use recursion
1. Use Array.Reverse
// Using Reverse
public static string ReverseString(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
public static string ReverseString(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
2. For loop
//Using For Loop to reverse string
public static string RevStrForLoop(string s)
{
int len = s.Length;
char[] arr = new char[len];
for (int i = 0; i < s.Length; i++)
{
arr[i] = s[len-i-1];
}
return new string(arr);
}
public static string RevStrForLoop(string s)
{
int len = s.Length;
char[] arr = new char[len];
for (int i = 0; i < s.Length; i++)
{
arr[i] = s[len-i-1];
}
return new string(arr);
}
3.Use Stack
public static string UsingStack(string s)
{
Stack<string> stack = new Stack<string>();
string rs = string.Empty;
for (int i=0; i<s.Length ; i++)
{
stack.Push(s.Substring(i,1));
}
for (int i = 0; i < s.Length; i++)
{
rs += stack.Pop();
}
return rs;
}
{
Stack<string> stack = new Stack<string>();
string rs = string.Empty;
for (int i=0; i<s.Length ; i++)
{
stack.Push(s.Substring(i,1));
}
for (int i = 0; i < s.Length; i++)
{
rs += stack.Pop();
}
return rs;
}
Subscribe to:
Comments (Atom)