11.
Which of the following statements are correct about exception handling in C#.NET?
try blocks cannot be nested.
In one function, there can be only one try block.
An exception must be caught in the same function in which it is thrown.
All values set up in the exception object are available in the catch block.
While throwing a user-defined exception multiple values can be set in the exception, object.
A. 1 only
B. 1 and 2 only
C. 3 only
D. 4 and 5 only
E. All of the above
Answer & Explanation
Answer: Option D
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
12.
Exceptions can be thrown even from a constructor, whereas error codes cannot be returned from a constructor.
A. True B. False
Answer & Explanation
Answer: Option A
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
13.
Which of the following statements is correct about the C#.NET program given below if a value “6” is input to it?
using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main (string[] args)
{
int index;
int val = 66;
int[] a = new int[5];
try
{
Consote.Write(“Enter a number: “);
index = Convert.ToInt32(Console.ReadLine());
a[index] = val;
}
catch(Exception e)
{
Console.Write(“Exception occurred “);
}
Console.Write(“Remaining program “);
}
}
}
A. It will output: Exception occurred
B. It will output: Remaining program
C. It will output: Exception occurred Remaining program
D. It will output: Remaining program Exception occurred
E. The value 66 will get assigned to a[6].
Answer & Explanation
Answer: Option C
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
14.
Which of the following statements is correct about the C#.NET program given below if a value “ABCD” is input to it?
using System;
namespace IndiabixConsoleApplication
{
class MyProgram
{
static void Main(string[] args)
{
int index;
int val = 55;
int[] a = new int[5];
try
{
Console.Write(“Enter a number: “);
index = Convert.ToInt32(Console.ReadLine());
a[index] = val;
}
catch(FormatException e)
{
Console.Write(“Bad Format “);
}
catch(IndexOutOfRangeException e)
{
Console.Write(“Index out of bounds “);
}
Console.Write(“Remaining program “);
}
}
}
A. It will output: Bad Format
B. It will output: Remaining program
C. It will output: Index out of bounds
D. It will output: Bad Format Remaining program
E. It will output: Index out of bounds Remaining program
Answer & Explanation
Answer: Option D
Explanation:
No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
15.
All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not.
A. True B. False
Answer & Explanation
Answer: Option A
Explanation:
No answer description available for this question.