Search Placementyogi.com
 

C# Exception Handling - Basic .NET Objective Questions

1

Exceptions in C#.NET occurs during

A.

compilation

B.

run-time

C.

just-in-time compilation

D.

linking

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

No explanation available. Let's Discuss

 
2

Which of the following options is a C#.NET exception class? (Multiple Choice)

A.

ArithmeticException & ArrayTypeMismatchException

B.

DivideByZeroException & IndexOutOfRangeException

C.

InvalidCastException & NullReferenceException

D.

OutOfMemoryException & OverflowException

E.

All of the above

See Answer & Explanation Lets Discuss
Correct answer is : E
Explanation

We have few more common exception classes such as Exception, StackOverflowException and TypeInitializationException.

 
3

If we don't use a try/catch block to handle the exception in C# program then which of the following component is responsible to catch it?

A.

Common Language Runtime (CLR)

B.

Compiler

C.

Linker

D.

Loader

See Answer & Explanation Lets Discuss
Correct answer is : A
Explanation

No explanation available. Let's Discuss

 
4

What is the output of the following C# program?

using System;
namespace PlacementYogi
{
    class MyProgram
    {
        static void Main(string[] args)
        {
            int a = 6;
            int b = 30;
            int result;
            try
            {
                result = b / (a - 6);
                Console.Write("result = " + result);
            }
            catch (DivideByZeroException e)
            {
                Console.Write("Divide by Zero exception : ");
            }
            Console.Write("Statements after exception");
        }
    }
}
A.

Divide by Zero exception :

B.

Divide by Zero exception : Statements after exception

C.

Statements after exception

D.

None of these

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

result = b / (a - 6) will give DivideByZeroException which will be caught by catch block and then statements after catch block will be executed.

 
5

What is the output of the following C# program?

using System;
namespace PlacementYogi
{
    class MyProgram
    {
        static void Main(string[] args)
        {
            int a = 6;
            int[] b = new int[9];
            int result;
            try
            {
                b[10] = a;
                result = b[10];
                Console.Write("result = " + result + " ");
            }
            catch (IndexOutOfRangeException e)
            {
                Console.Write("Index out of bound exception : ");
            }
            Console.Write("Statements after exception");
        }
    }
}
A.

result = 6

B.

result = 6 Statements after exception

C.

Index out of bound exception :

D.

Index out of bound exception : Statements after exception

E.

None of these

See Answer & Explanation Lets Discuss
Correct answer is : D
Explanation

Since we have declared an array of 10 elements indexed from 0 to 9 so there is no index as 10 hence it throws the exceptoin which is caught by the catch block.

 
 

Banner to LogicGuns.com

Hide Page Information

C# Exception Handling - Basic .NET Objective Questions and Answers with Explanation

Here you can find basic level C# Exception Handling interview questions with answers and explanation.

Why Exception Handling in C#?

In this section you can learn and practice different types of basic level questions with answers on exception handling to improve your skills in order to face the interviews,competitive examinations and various entrance tests with full confidence.

Where can I get C# Exception Handling Basic Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved advanced level exception handling questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand. All students, freshers can download quiz questions with answers as PDF files and eBooks.

Where can I get Basic Level C# Exception Handling Interview Questions and Answers (objective type, multiple choice)?

Here you can find objective type basic exception handling questions and answers for interview and entrance examination. Multiple choice and TRUE or FALSE type and YES or NO type questions are also provided.