.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> OOPS >> Post New Question Subscribe to Interview Questions

Why 'static' keyword is used before Main()?

Posted By :Abhisek Panda     Posted Date :February 26, 2010    Points :10   Category :OOPS 
Program execution starts from Main(). S it should be called before the creation of any object. By using static the Main() can now be called directly through the class name and there is no need to create the object to call it. So Main() is declared as static.

You can also find related Interview Question to Why ''static'' keyword is used before Main()?  below: 

Consider the following code:

public class Example extends Thread
public void run()
System.out.println ("Hello");

public static void main (String args[])
new Example();

Select the correct option regarding the preceding code ?

1, The code will not compile.
2, The code will compile but will not execute.
3, The code will compile, execute, and display Hello as the output.
4, The code will compile, execute, but will not display anything.

Answer : 4 (More...)

Consider the following two classes:

public class Example1
public static int num;

public class Example2
public static void main(String[] args)

Select the correct option regarding the preceding classes.?

1, The Example2 class will execute without any output.
2, The Example2 class will execute with the following output:5

3, The Example2 class will not compile as it does not calls the constructor of the Example 1 class.
4, The Example2 class will not execute as it does not calls the constructor of the Example 1 class.

Answer : 2 (More...)

Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

(Class constructor method is also known as type constructor or type initializer)
Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention. (More...)

Yield keyword in C Sharp

C Sharp and yield keyword


One of the cool and yet most unknown feature of the C# is the yield keyword. The yield keyword is used in an iterator block to provide a value to the enumerator object or to signal the end of the iteration. When used the expression is evaluated and returned as a value to the enumerator object. Note the expression has to be implicitebly convertible to yield type of the iterator. Here is an example

public static IEnumerable GetIntCollectionFromString(string SomeString){ string[] val = SomeString.Split(' '); int intToAdd; foreach (string token in val) { if (int.TryParse(token, out intVal)) { yield return intVal; } else { yield break; } }}

Here since we are using the yield keyword the function will return the collection of intVal instead of the value of intVal. The statement will only return when the iteration of the loop is complete.

There are some limitation with the yield keywords.

Unsafe blocks are not allowed
Parameters to the method, operator, or accessor cannot be ref or out. (More...)

What is the main purpose of having Conversation Group?

It's a way of grouping all the dialogs that are used for a particular task. All the dialogs associated with processing a particular order would be grouped into a single conversation group. The conversation group is implemented as a conversation group identifier, which is included with all messages in all dialogs contained in the conversation group. When a message is received from any of the dialogs in a conversation group, the conversation group is locked with a lock that is held by the receiving transaction. For the duration of the transaction, only the thread that holds the lock can receive messages from any of the dialogs in the conversation group. This makes our order entry application much easier to write because even though we use many threads for scalability, any particular order is only processed on one thread at a time. This means we don't have to make our application resilient to problems that are caused by the simultaneous processing of a single order on multiple threads. (More...)

What is the Main Difference between ASP and ASP.NET?

ASP Contains Scripts which are not complied where as in asp.net the code is compiled (More...)

What are the main benefits of Office SharePoint Server 2007?

Office SharePoint Server 2007 provides a single integrated platform to manage intranet, extranet,and Internet applications across the enterprise.

* Business users gain greater control over the storage, security, distribution, and management of their electronic content, with tools that are easy to use and tightly integrated into familiar,everyday applications.

* Organizations can accelerate shared business processes with customers and partners across organizational boundaries using InfoPath Forms Services-driven solutions.

* Information workers can find information and people efficiently and easily through the-facilitated information-sharing functionality and simplified content publishing. In addition, access to back-end data is achieved easily through a browser, and views into this data can be personalized.

* Administrators have powerful tools at their fingertips that ease deployment, management, and system administration, so they can spend more time on strategic tasks.

* Developers have a rich platform to build a new class of applications, called Office Business Applications, that combine powerful developer functionality with the flexibility and ease of deployment of Office SharePoint Server 2007. Through the use of out-of-the-box application services, developers can build richer applications with less code. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend