C# Interview Questions and Answers Part 3

1)    What is the output??

static void Main(string[] args)

    { 

        int i=1;

        do

        {

            Console.WriteLine(i);

        }

        while (i >= 10);

        Console.ReadLine();      

    }

OUTPUT :  

        1

2)    What is the output?

static void Main(string[] args)

    {

        int i=1;

        for (; ; )

        {

            Console.WriteLine(i);

            i++;

        }

        Console.ReadLine();      

    }

OUTPUT :  

1

2

3

4

5

N

Infinite loop

         

3)    Which of the following are value types?

A.   int              B.  class           C.  Single          D.  String                      E.  Long

 

Ans:-A,C,E

4)   Which of the following are the correct way to initialize the variables i and j to a value 10 each?

  1. int i = 10; int j = 10;
  2. int i, j;
  3. i = 10 : j = 10;
  4. int i = 10, j = 10;
  5. int i, j = 10;
  6. int i = j = 10;

Ans:-1,4

5)   What is output?

static void Main(string[] args)

    {

        string s1 ="10";

        string s2 ="20";

        string s3=s1+s2;

        int res=int.Parse(s3);

        Console.WriteLine(res);

        Console.ReadLine();

      }

OUTPUT :   -

1020






Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker