Welcome to the Quiz on Programming in C#

1. What will be the output of following code?using System;
namespace MyApplication1
{
class MyClass
{
static void Main(string[] args)
{
byte a = 200;
byte b = 230;
byte c = a + b;
Console.WriteLine($"Sum = {c}");
}
}
}
2. What will be the output of following code?using System;
namespace MyApplication1
{
class MyClass
{
static void Main(string[] args)
{
byte a = 200;
byte b = 230;
byte c = (byte)(a + b);
Console.WriteLine($"Sum = {c}");
}
}
}
3. What is the error in following code?double a = 200;
int b = 230;
int c = a + b;
Console.WriteLine($"Sum = {c}");
4. What is the error in following code?int a = 200;
int b = 230;
double c = a + b;
Console.WriteLine($"Sum = {c}");
5. What will happen if you execute following code?int c;
Console.WriteLine($"C = {c}");
6. What is the reason of error in following code?int a;
byte b;
double c;
c = a + b;
7. What is the output of following code?int a=2;
byte b=3;
double c;
c = a + b;
Console.WriteLine("Sum of {0} and {1} is {2}", a, b);
8. What is the output of following code?sbyte a=-20;
sbyte b=-30;
byte c;
c = (byte)(a + b);
Console.WriteLine(c);
9. What is wrong with following statement?int c = 3 + 4M;
10. What is the error in following code?ulong x = 5;
long i = 9;
i = x;
x = i;

Leave a Reply

Your email address will not be published. Required fields are marked *