Toars I will smile to the world ^o^

11Nov/100

C# Questions and Answers – 01

  • What’s the advantage of using System.Text.StringBuilder over System.String?
    StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.
  • Can you store multiple data types in System.Array?
    No.
  • What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?
    The first one performs a deep copy of the array, the second one is shallow.
  • How can you sort the elements of the array in descending order?
    By calling Sort() and then Reverse() methods.
  • What’s the .NET datatype that allows the retrieval of data by a unique key?
    HashTable.
  • What’s class SortedList underneath?
    A sorted HashTable.
  • Will finally block get executed if the exception had not occurred?
    Yes.
  • What’s the C# equivalent of C++ catch (…), which was a catch-all statement for any possible exception?
    A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.
  • Can multiple catch blocks be executed?
    No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.
  • Why is it a bad idea to throw your own exceptions?
    Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.
  • What’s a delegate?
    A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.
  • What’s a multicast delegate?
    It’s a delegate that points to and eventually fires off several methods.
  • How’s the DLL Hell problem solved in .NET?
    Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
  • What are the ways to deploy an assembly?
    An MSI installer, a CAB archive, and XCOPY command.
  • What’s a satellite assembly?
    When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
  • What namespaces are necessary to create a localized application?
    System.Globalization, System.Resources.
  • What’s the difference between // comments, /* */ comments and /// comments?
    Single-line, multi-line and XML documentation comments.
  • How do you generate documentation from the C# file commented properly with a command-line compiler?
    Compile it with a /doc switch.
  • What’s the difference between and XML documentation tag?
    Single line code example and multiple-line code example.
  • Is XML case-sensitive?
    Yes, so and are different elements.
  • What debugging tools come with the .NET SDK?
    CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
  • What does the This window show in the debugger?
    It points to the object that’s pointed to by this reference. Object’s instance data is shown.
  • What does assert() do?
    In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
  • What’s the difference between the Debug class and Trace class?
    Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
  • Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
    The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.
  • Where is the output of TextWriterTraceListener redirected?
    To the Console or a text file depending on the parameter passed to the constructor.
  • How do you debug an ASP.NET Web application?
    Attach the aspnet_wp.exe process to the DbgClr debugger.
  • What are three test cases you should go through in unit testing?
    Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
  • Can you change the value of a variable while debugging a C# application?
    Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
  • Explain the three services model (three-tier application).
    Presentation (UI), business (logic and underlying code) and data (from storage or other sources).
  • What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?
    SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.
  • What’s the role of the DataReader class in ADO.NET connections?
    It returns a read-only dataset from the data source when the command is executed.
  • What is the wildcard character in SQL?
    Let’s say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve ‘La%’.
  • Explain ACID rule of thumb for transactions.
    Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).
  • What connections does Microsoft SQL Server support?
    Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords).
  • Which one is trusted and which one is untrusted?
    Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
  • Why would you use untrusted verificaion?
    Web Services might use it, as well as non-Windows applications.
  • What does the parameter Initial Catalog define inside Connection String?
    The database name to connect to.
  • What’s the data provider name to connect to Access database?
    Microsoft.Access.
  • What does Dispose method do with the connection object?
    Deletes it from the memory.
  • What is a pre-requisite for connection pooling?
    Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.
Filed under: Interviews No Comments
10Nov/100

Stupid Interview Questions

It isn't much fun being a corporate human resources person, but the job offers one treat: You get to dream up outlandish interview questions to throw at job candidates, then watch them squirm. Some of these goofy questions are time-honored -- they may not be useful, but they've become an HR tradition. Others are hot off the press. Here's a tour through the world of wacky queries -- so you'll be prepared the next time you're hit with one in an interview:

Where do you see yourself in five years?
This is the great-granddaddy of goofy questions, and I give you permission, if you have any misgivings about a job opportunity, to walk out the door when you hear it. It's such a time-waster that only the most hidebound interviewers will utter it, but it lives on.

Here's why it's dumb. No company will guarantee you a job for five years, much less a career path. To construct such a plan for yourself, you'd have to make predictions about industries, companies, and your likes and dislikes that could only serve to constrain your choices. And in any case, why is it so all-fired important to have a dang career plan in mind? Every successful entrepreneur and many top corporate people will tell you their key to success: I did what I felt driven to do at the moment.

So when you get asked this question, you can say: "I intend to be happy and productive five years from now, working at a job I love in a company that values my talents" and leave it at that. Or you can give the expected answer and say: "I hope to be three levels up the ladder, here at Happy Corp." Or you can say: "I hope to own this company," just to shake things up.

But for an interviewer to ask the question at all is a bad sign. Come on, people! There are millions of thoughts in the human brain. Can we change the ones we use in job interviews every decade or so?

If you were an animal/a can of soup/some other random object, which one would you be?
This is a question typically asked of new grads, because it's considered cute. It's supposed to test how people think. But it's asinine. You can pretend to think about your answer for a moment (eyes to the ceiling, chin resting on hand) and then come up with something. Or stare blankly at the interviewer and say, deadpan: "Are you serious?" Or try one of these answers:

(Animal) "Oh, any crepuscular animal would do well for me -- a rabbit or a bat, perhaps." (Crepuscular means most active during dawn and dusk, so you'll get to show off your extensive vocab.)

(Soup) "Probably the low-sodium chicken broth." Fix the interviewer with a penetrating gaze -- she won't know whether you're mocking her imbecilic question or are deadly serious.

What are your weaknesses?
By now, such a large percentage of the job-seeking public has gotten clued in on the politically correct answer to this one -- which is, "I'm a hopeless workaholic" -- that the question's utility is limited. But it's also offensive.

This is a job interview, not a psychological exam. It's one thing for an interviewer to ask you what you do particularly well. It's another thing to ask what you don't do well and expect to get a forthright answer -- in a context where it's clear to both parties that you're being weeded in or out. The most honest answer might be this: "That's for me to know and you to find out." But that won't help your chances.

So if you can't bear to repeat the "workaholic" line, I'd say something that is true of yourself but also terribly common -- like the fact that you get bored easily, or prefer numbers to people or vice versa. None of these is actually a weakness, but that's O.K.

What in particular interested you about our company?
Now, on one level this is a reasonable question. If you say: "I'm interested in this job because it's three blocks from my apartment," you might not be the world's best candidate. But the disingenuous, and therefore offensive, aspect of this question is that it assumes that you have unlimited job opportunities and have pinpointed this one because of some dazzling aspect of the role or the company.

I mean, please. Most of the job-seeking population is living on the lower two-thirds of Maslow's pyramid, where the most appealing thing about any job is that you got the darned interview. Why am I interested? Because you guys called me back. But you can't say that, so you have to rhapsodize about the company's wonderful products and services and the world-class management team and so on.

Now, it's important to show that you know a lot about the company. But you have lots of ways to demonstrate that in an interview (and lots of ways for the interviewer to ask you to do so) without pretending that the company had to fight every employer in town to get an audience with you. Everybody involved knows the company is shredding 10 times the number of résumés it's reading, so let's not pretend it was your breathtaking credentials that got you the interview. It was the fact that the company responded to your overture, unlike 90% of the employers you contacted.

Below the director level or so, where it might be reasonable to assume you sought out the company for particular job-hunting attention, it's not necessary to pretend that you carefully chose it from a raft of others pursuing you. So unless you approached the outfit in the absence of a posted job opportunity, it's just silly to ask: "Why us?"

Rather, the interviewer can say: "When you saw our ad on Monster.com, what made you respond?" And, of course, the logical answer is: "Because I know I can do the job that was posted." Duh. No one said job-hunting was easy.

What would your past managers say about you?
This is a fine question, but it's not a true interview question. It's an intelligence question. It's like the question on one of those "honesty" tests that are becoming more and more popular in the hiring process (to add insult to injury, they're often called Personality Profiles): "Do you think it's O.K. to steal from your employer?"

These are intelligence questions because you have to have the intelligence to know the answer in order to be smart enough to go and get a job.

The trick here is to say something sufficiently witty or pithy to make you stand out from the crowd, because the standard answers are so tired: My managers would say that I'm hard-working, loyal, reliable, and a great team player. Snoozeville.

Why not try: My past managers would say that I was an outstanding individual contributor who also supported the team 100%. Or: My managers would say that I came up with breakthrough solutions while never losing track of the bottom line. You can probably dream up something better.

The point is, this is a softball: Don't think too much about it. It says more about the interviewer (who lacks the moxie to think up unique or penetrating questions) than it ever will about you.

The secret of good job interviewers is that they never ask traditional, dorky interview questions. They don't need to. They jump into a business conversation that does three powerful things in a one-hour chat:

a) Gets you excited about this opportunity (or, as valuably, makes it clear that you and this job are not a good fit)
b) Reveals to the interviewer how you'll fit into the role and the company, based on your background, perspective, temperament, and ideas
c) Gives you a ton of new information about the job, the management, the goals, the culture, and what life at this joint would be like.

If any of this doesn't happen, it's a problem. If you're lukewarm on the job when you leave the interview, or if you don't feel you've had a chance to show what you know and how you think, or -- worst of all -- if the interviewer used your time together to satisfy his need for more information about you while sharing almost nothing about the job, that's an enormous red flag.

And if you get called back for a second interview while you're still information-deprived, say so. "I'm interested in learning more about the opportunity before a second interview," you can say. "Would a phone call with the hiring manager be an effective way to help me get up to speed?" That kind of suggestion respects the hiring manager's time and won't waste yours on a second, no-new-data interview.

Try it. You might save yourself some aggravation -- along with some extra time you can use to work on your five-year career plan and on tackling those pesky weaknesses of yours before the next interview.

Filed under: Interviews No Comments