C# Interview Questions and Answers Part 6

1)   What is the output?

static void Main(string[] args)

    {

        char x = 'a';

        int i = x;

        Console.WriteLine(i);

        char y = '1';

        int j = y;

        Console.WriteLine(j);

        Console.ReadLine();  

    }

OUTPUT :  

97

49

2)   What is the output?

 static void Main(string[] args)

    {

        string s="10";

        int a = int.Parse(s);

        Console.WriteLine(a);

        Console.ReadLine();   

    }

OUTPUT :  

10

 

 

3)   What is the output?

static void Main(string[] args)

    {

        string s="dotnet";

        int a = int.Parse(s);

        Console.WriteLine(a);

        Console.ReadLine();   

    }

OUTPUT :  

Input string was not in a correct format

 

4)   What is the output?

static void Main(string[] args)

    {

        char a = '1';

        Console.WriteLine(a);

        Console.ReadLine();  

    }

OUTPUT :  

1

 

5)   What is the output?

static void Main(string[] args)

    {

        char a = 'xy';

        Console.WriteLine(a);

        Console.ReadLine();  

    }

OUTPUT :  

Error    1          Too many characters in character literal          

 






Subscribe

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

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker