Thursday, August 6, 2009

C# InterviewQuestions-Part 10

Interview Questions
----------------------
91. How many types of errors are there?
a ) 2 types
1. Run time errors
2. Compile time errors

92. Give some examples of compile time and runtime errors?
a ) Compile time:
missing semocolons
use of undeclared variables
bad references to objects
runtime:
dividing an integer by zero
using negative size for an array
passing a parameter that is not in a valid range

93. What is an exception?
a ) An exception is a condition that occurs by a run time error in the program

94. What is the base class used for all the exceptions in c#?
a ) It is Exception

95. Why do we use throw keyword?
a ) Throw keyword is used to throw our own exceptions.

96. How many exceptions we can write in throws clause?
a ) We can use multiple exceptions.

97. Can a finally block exists with try block but without a catch block?
a ) Yes

98. Can we have nested try blocks in c#?
a ) yes

99. What is the difference between Write() and WriteLine() methods?
a ) Write() method outputs one or more values to the screen without a newline character
WriteLine() method outputs one or more values to the screen with a newline character

100. What is the difference between Read() and Readline() methods?
a ) Read() method returns a single character as int
ReadLine() method returns a string containing a line of text