1. What will be the output of the following C# code snippet?
class Output
{
public static void main(String args[])
{
try
{
int a = 10;
int b = 5;
int c = b - 5 / 5;
Console.WriteLine("Hi");
}
catch(Exception e)
{
Console.WriteLine("hello");
}
}
}
class Output
{
public static void main(String args[])
{
try
{
int a = 10;
int b = 5;
int c = b - 5 / 5;
Console.WriteLine("Hi");
}
catch(Exception e)
{
Console.WriteLine("hello");
}
}
}2. Choose the correct alternative that utilizes the indexed property such that a group named class has indexed property which stores or retrieves value to/from an array of 5 numbers?
3. Which among the following are the advantages of using indexers?
4. What will be the output of the following C# code snippet?
class Program
{
static void Main(string[] args)
{
int i;
int v = 40;
int[] x = new int[5];
try
{
Console.WriteLine(" Enter the number: ");
index = Convert.ToInt32(Console.ReadLine());
x[index] = v;
}
catch(Exception e)
{
Console.WriteLine("Exception occurred");
}
Console.WriteLine("Program executed");
}
}
class Program
{
static void Main(string[] args)
{
int i;
int v = 40;
int[] x = new int[5];
try
{
Console.WriteLine(" Enter the number: ");
index = Convert.ToInt32(Console.ReadLine());
x[index] = v;
}
catch(Exception e)
{
Console.WriteLine("Exception occurred");
}
Console.WriteLine("Program executed");
}
}5. Which of these keywords must be used to monitor exceptions?
6. Select the correct statement about properties of read and write in C#.NET?
7. Consider a class maths and we had a property called a sum.b is a reference to a maths object and we want the statement b.sum = 10 to fail. Which of the following is the correct solution to ensure this functionality?
Read More Section(Exception Handling in C Sharp)
Each Section contains maximum 100 MCQs question on Exception Handling in C Sharp. To get more questions visit other sections.
