adplus-dvertising
frame-decoration

Question

Choose the output for the given set of code:
static void Main(string[] args)
 {
     int a = 10, b = 0;
     int result;
     Console.Out.WriteLine("This will generate an exception.");
     try
     {
         result = a / b; // generate an exception
     }
     catch (DivideByZeroException exc)
     {
         Console.Error.WriteLine(exc.Message);
     }
     Console.ReadLine();
 }

a.

This will generate an exception

b.

0

c.

Compile time error

d.

This will generate an exception
Attempted to Divide by Zero

Answer: (a).This will generate an exception

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Choose the output for the given set of code:

Similar Questions

Discover Related MCQs

Q. Choose the methods provided by Console.Out and Console.Error?

Q. Name the exception thrown by read() on failure.

Q. Which of these methods are used to read single character from the console?

Q. Which of these method used to read strings from the console?

Q. Which among the following methods are used to write characters to a string?

Q. Which method in Console enables to read individual inputs directly from the keyboard in a non line buffered manner?

Q. What is the output returned by Console if ReadLine() stores I/O error?

Q. Name the method/methods used to read byte streams from the file?

Q. Which of these classes are used by Byte streams for input and output operation?

Q. Which of these method/methods are used to read block or array of bytes from the file?

Q. Select the objects of the class TextWriter which is/are not used to perform the write operations to the console?

Q. Choose the correct statement about the WriteLine()?

Q. Which of the following statement is correct?

Q. Which of these classes is used to create an object whose character sequence is mutable?

Q. Select the namespace/namespaces which consists of methods like Length(), Indexer(), Append() for manipulating the strings.

Q. Select the method used to write single byte to a file?

Q. Select the namespace on which the stream classes are defined?

Q. Choose the class on which all stream classes are defined?

Q. Choose the stream class method which is used to close the connection:

Q. The method used to write a single byte to an output stream?