Question:
How to get the Current Year in SQL ?
Answer:
select Year(GetDate())
HappyCoding ! π
Archive for August, 2012
7 Aug
Question of the day :Day 8
Question of the day.
This is a perplexing question that has been asked to me by an interviewer long back.I thought of sharing it with u. He asked me about the difference between string and string builder.I gave him an impressive answer.The answer that i gave him was efficient memory management that can be achieved using string builder.
You can view my previous post on String and String Builder for more details.
Then he asked me a question linking garbage collector to it. Since garbage collector automatically remove unwanted objects. why do we need a string builder?
I told him that garbage collector is unpredictable. The moment when the garbage is actually collected can be unpredictable, resulting in stalls scattered throughout a session. he was not satisfied with my answer.So today’s Question is all about Garbage collector.We know the advantages of using Garbage collector.But it has some disadvantages too. lets have a detailed look on it.
Question:
What are the Disadvantages of Garbage Collector?
Answer:
HappyCoding ! π
7 Aug
Question of the day :Day 6
Question:
What is a Static class and Why do wee need it?
Answer:
The Word Static means unchangeable or not moving or fixed.So a static class means whose value is fixed in the Memory.Static classes are light weight and don’t need instantiation.It is not possible to create instances of a static class using the new keyword.A static class cannot have non-static members.Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created. thus you can say that Static Class is an Example of Data Hiding.
Static classes are sealed and therefore cannot be inherited.
When you want to restrict the class from creating any objects of its we can go for a static class
HappyCoding ! π