C# Programming Questions and Answers
Which of these methods are used to read single character from the console?
Answer: Option (C)
Which method in Console enables to read individual inputs directly from the keyboard in a non line buffered manner?
The .NET Framework includes a method in Console that enables you to read individual keystrokes directly from the keyboard, in a non-line-buffered manner. This method is called ReadKey().When it is called, it waits until a key is pressed. When the key is pressed, ReadKey( ) returns the keystroke immediately
Name the exception thrown by read() on failure.
read() throws I/O exception on failure.
Which among the following methods are used to write characters to a string?
The stream class method writes characters to the string.
Which of these method used to read strings from the console?
Answer: Option (D)
Name the method/methods used to read byte streams from the file?
Answer: Option (A) and (B)
Which of these method/methods are used to read block or array of bytes from the file?
To read a block of bytes, use Read( ), which has this general form:
int Read(byte[ ] array, int offset, int count)
What would be the output for following input from the console as a character?
staticvoid Main(string[] args)
{
Console.WriteLine("what is your name?");
char s;
s = Convert.ToChar(Console.ReadLine());
Console.WriteLine("how are you: "+s);
Console.Read();
}
Since only a single character is required to be entered on console when a string is entered , a run time exception is being generated as we had not used Read() which reads single character but used readLine() which reads string and is converted into the char using convert.tochar().
Which of these classes are used by Byte streams for input and output operation?
Byte stream uses InputStream and OutputStream classes for input and output operation.
What is the output returned by Console if ReadLine() stores I/O error?
Answer: Option (D)