AmbitionBox

Discover Best Places to work in India

C# Programming

C# Programming Questions and Answers

Showing 1 - 7 of 7 questions

1

Which among the following is NOT considered as .NET Exception class?

a

Exception

b

StackUnderflow Exception

c

File Found Exception

d

Divide By zero Exception

correct answer b,c

Answer: Option (B) and Option (C)

2

Select the statements which describe the correct usage of exception handling over conventional error handling approaches?

a

As errors can be ignored but exceptions cannot be ignored

b

Exception handling allows separation of program’s logic from error handling logic making software more reliable and maintainable

c

try – catch – finally structure allows guaranteed cleanup in event of errors under all circumstances

d

All of the above mentioned

correct answer d

Answer: Option (D)

3

Which among the following is NOT an exception?

a

Stack Overflow

b

Arithmetic Overflow or underflow

c

Incorrect Arithmetic Expression

d

All of the above mentioned

correct answer c

Answer: Option (C)

4

Which of the following is the correct statement about exception handling in C#.NET?

a

finally clause is used to perform cleanup operations of closing network and database connections

b

a program can contain multiple finally clauses

c

The statement in final clause will get executed no matter whether an exception occurs or not

d

All of the above mentioned

correct answer a,c

Answer: Option (A) and Option (C)

5

Which of these keywords is not a part of exception handling?

a

try

b

finally

c

thrown

d

catch

correct answer c

Exception handling is managed via 5 keywords – try, catch, throws, throw and finally.

6

Choose the correct output for the given set of code:

class program

{

     staticvoid main(string[] args)

     {

          int i =5;

          int v =40;

          int[] p =newint[4];

          try

          {

               p[i]= v;

          }

          catch(IndexOutOfRangeException e)

          {

               Console.WriteLine("Index out of bounds");

          }

          Console.WriteLine("Remaining program");

     }

}

 

 

 

a

value 40 will be assigned to a[5];

b

The output will be :
Index out of bounds
Remaining program

c

The output will be :
Remaining program

d

None of the above mentioned

correct answer b

Answer: Option (B)

7

Choose the correct output for the given set of code:

staticvoid Main(string[] args)

{

     try

     {

          Console.WriteLine("csharp"+" "+1/Convert.ToInt32(0));

     }

     catch(ArithmeticException e)

     {

          Console.WriteLine("Java");

     }

     Console.ReadLine();

}

a

csharp

b

java

c

Run time error

d

csharp 0

correct answer c

1 / 0, hence system out of flow exception error.

Select a company to compare with

vs

Similar Companies