71. If math class had add property with get and set accessors, then which of the following statements will work correctly?
72. Which of these clauses will be executed even if no exceptions are found?
73. Choose the statements which makes use of essential properties rather than making data member public in C#.NET?
74. What will be the output of the following C# code?
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("csharp" + " " + 1/0);
}
finally
{
Console.WriteLine("Java");
}
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("csharp" + " " + 1/0);
}
finally
{
Console.WriteLine("Java");
}
Console.ReadLine();
}
}
75. What will be the output of the following C# code?
{
int sum = 10;
try
{
int i;
for (i = -1; i < 3; ++i)
sum = (sum / i);
}
catch (ArithmeticException e)
{
Console.WriteLine("0");
}
Console.WriteLine(sum);
Console.ReadLine();
}
{
int sum = 10;
try
{
int i;
for (i = -1; i < 3; ++i)
sum = (sum / i);
}
catch (ArithmeticException e)
{
Console.WriteLine("0");
}
Console.WriteLine(sum);
Console.ReadLine();
}
76. What will be the output of the following C# code?
class number
{
private int num1;
private int num2;
public int anumber
{
get
{
return num1;
}
set
{
num1 = value;
}
}
public int anumber1
{
get
{
return num2;
}
set
{
num2 = value;
}
}
}
class Program
{
public static void Main(string[] args)
{
number p = new number();
p.anumber = 20;
number k = new number();
k.anumber1 = 40;
int m = p.anumber;
int t = k.anumber1;
int r = p.anumber + k.anumber1;
System.Console.WriteLine("number1 = " +m);
System.Console.WriteLine("number2 = " +t);
System.Console.WriteLine("sum = " +r);
System.Console.ReadLine();
}
}
class number
{
private int num1;
private int num2;
public int anumber
{
get
{
return num1;
}
set
{
num1 = value;
}
}
public int anumber1
{
get
{
return num2;
}
set
{
num2 = value;
}
}
}
class Program
{
public static void Main(string[] args)
{
number p = new number();
p.anumber = 20;
number k = new number();
k.anumber1 = 40;
int m = p.anumber;
int t = k.anumber1;
int r = p.anumber + k.anumber1;
System.Console.WriteLine("number1 = " +m);
System.Console.WriteLine("number2 = " +t);
System.Console.WriteLine("sum = " +r);
System.Console.ReadLine();
}
}
77. Choose the correct statement among the followings?
78. What will be the output of the following C# code?
class list
{
ArrayList array = new ArrayList();
public object this[int index]
{
get
{
if (index < 0 || index >= array.Count)
{
return null;
}
else
{
return (array[index]);
}
}
set
{
array[index] = value;
}
}
public int Count
{
get;
set;
}
}
class Program
{
static void Main(string[] args)
{
list list1 = new list();
list1[0] = "123";
list1[1] = " abc ";
list1[2] = "xyz";
for (int i = 0; i<=list1.Count; i++)
Console.WriteLine(list1[i]);
Console.ReadLine();
}
}
class list
{
ArrayList array = new ArrayList();
public object this[int index]
{
get
{
if (index < 0 || index >= array.Count)
{
return null;
}
else
{
return (array[index]);
}
}
set
{
array[index] = value;
}
}
public int Count
{
get;
set;
}
}
class Program
{
static void Main(string[] args)
{
list list1 = new list();
list1[0] = "123";
list1[1] = " abc ";
list1[2] = "xyz";
for (int i = 0; i<=list1.Count; i++)
Console.WriteLine(list1[i]);
Console.ReadLine();
}
}
79. If the math class had add property with get accessors then which of the following statements will work correctly?
80. What will be the output of the following C# code?
class number
{
private int num1 = 60;
private int num2 = 20;
public int anumber
{
get
{
return num1;
}
set
{
num1 = value;
}
}
public int anumber1
{
get
{
return num2;
}
set
{
num2 = value;
}
}
}
class Program
{
public static void Main(string[] args)
{
number p = new number();
number k = new number();
int m = p.anumber;
int t = k.anumber1;
int r = p.anumber * k.anumber1;
Console.WriteLine("sum = " + r);
Console.ReadLine();
}
}
class number
{
private int num1 = 60;
private int num2 = 20;
public int anumber
{
get
{
return num1;
}
set
{
num1 = value;
}
}
public int anumber1
{
get
{
return num2;
}
set
{
num2 = value;
}
}
}
class Program
{
public static void Main(string[] args)
{
number p = new number();
number k = new number();
int m = p.anumber;
int t = k.anumber1;
int r = p.anumber * k.anumber1;
Console.WriteLine("sum = " + r);
Console.ReadLine();
}
}
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.