InterviewSolution
Saved Bookmarks
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
Which of the given stream methods provide access to the output console by default in C#.NET?(a) Console.In(b) Console.Out(c) Console.Error(d) All of the mentioned |
|
Answer» Correct answer is (b) Console.Out The best I can explain: The standard output stream Console.Out sends output to the screen by default. |
|
| 52. |
Which of the classes provide the operation of reading from and writing to the console in C#.NET?(a) System.Array(b) System.Output(c) System.ReadLine(d) System.Console |
|
Answer» The correct option is (d) System.Console To explain I would say: The method for reading and writing to the console in C#.NET is provided by System.Console class. This class gives us access to the standard input, output and standard error streams. |
|
| 53. |
Which of the given stream methods provide access to the input console in C#.NET?(a) Console.Out(b) Console.Error(c) Console.In(d) All of the mentioned |
|
Answer» Correct option is (c) Console.In Explanation: Console.In is an instance of TextReader, and we can use the methods and properties defined by TextReader to access it to read the input from the keyboard. |
|
| 54. |
Choose the stream class method which is used to close the connection?(a) close()(b) static close()(c) void close()(d) none of the mentioned |
|
Answer» Correct option is (c) void close() The best I can explain: void close() closes the stream. |
|
| 55. |
The method used to write a single byte to an output stream?(a) void WriteByte(byte value)(b) int Write(byte[] buffer ,int offset ,int count)(c) write()(d) none of the mentioned |
|
Answer» Right choice is (a) void WriteByte(byte value) The explanation is: Writes a single byte to an output stream. |
|
| 56. |
Select the method which returns the number of bytes from the array buffer:(a) void WriteByte(byte value)(b) int Write(byte[] buffer, int offset, int count)(c) write()(d) none of the mentioned |
|
Answer» Correct option is (b) int Write(byte[] buffer, int offset, int count) Best explanation: Writes a subrange of count bytes from the array buffer, beginning at buffer[offset], returning the number of bytes written. |
|
| 57. |
Select the method which writes the contents of the stream to the physical device.(a) fflush()(b) void fflush()(c) void Flush()(d) flush() |
|
Answer» Correct answer is (c) void Flush() Easiest explanation - The method used to write the contents of the stream to the physical device. |
|
| 58. |
Choose the class on which all stream classes are defined?(a) System.IO.stream(b) Sytem.Input.stream(c) System.Output.stream(d) All of the mentioned |
|
Answer» Correct answer is (a) System.IO.stream The best explanation: The core stream class is System.IO.Stream. Stream represents a byte stream and is a base class for all other stream classes. It is also abstract, which means that you cannot instantiate a Stream object. Stream defines a set of standard stream operations. |
|
| 59. |
Select the namespace on which the stream classes are defined?(a) System.IO(b) System.Input(c) System.Output(d) All of the mentioned |
|
Answer» The correct answer is (a) System.IO To explain: The core stream classes are defined within the System.IO namespace. To use these classes, you will usually include the following statement near the top of your program: using System.IO; |
|
| 60. |
Choose the filemode method which is used to create a new output file with the condition that the file with same name must not exist.(a) FileMode.CreateNew(b) FileMode.Create(c) FileMode.OpenOrCreate(d) FileMode.Truncate |
|
Answer» Correct option is (a) FileMode.CreateNew The explanation: Creates a new output file. The file must not already be existing. |
|
| 61. |
Which of these classes is used to read and write bytes in a file?(a) FileReader(b) FileWriter(c) FileInputStream(d) InputStreamReader |
|
Answer» Correct choice is (c) FileInputStream Explanation: None. |
|
| 62. |
Which of these data types is returned by every method of OutputStream?(a) int(b) float(c) byte(d) none of the mentioned |
|
Answer» Correct option is (d) none of the mentioned To explain I would say: Every method of OutputStream returns void and throws an IOExeption in case of errors. |
|
| 63. |
Which of these classes is used for input and output operation when working with bytes?(a) InputStream(b) Reader(c) Writer(d) All of the mentioned |
|
Answer» Correct choice is (a) InputStream To explain I would say: InputStream & OutputStream are designed for byte stream. Reader and writer are designed for character stream. |
|
| 64. |
Select the action of the method long seek()?(a) Attempts to readup to count bytes into buffer starting at buffer[offset](b) Writes a single byte to an output stream(c) Sets the current position in the stream to the specified offset from specified origin and hence returns the new position(d) None of the mentioned |
|
Answer» The correct answer is (c) Sets the current position in the stream to the specified offset from specified origin and hence returns the new position To explain I would say: long Seek(long offset, SeekOrigin origin) Sets the current position in the stream to the specified offset from the specified origin. It returns the new position. |
|
| 65. |
Which of these is a method used to clear all the data present in output buffers?(a) clear()(b) flush()(c) fflush()(d) close() |
|
Answer» Correct answer is (b) flush() The explanation is: None. |
|
| 66. |
Which of the following is used to perform all input & output operations in C#?(a) streams(b) Variables(c) classes(d) Methods |
|
Answer» Correct option is (a) streams The best explanation: Streams are used for input and output operations in any programming language. |
|
| 67. |
Which method among the following returns the integer if no character is available?(a) int peek()(b) int read()(c) string ReadLine()(d) none of the mentioned |
|
Answer» The correct choice is (a) int peek() The best explanation: Obtains the next character from the input stream, but does not remove that character. Returns –1 if no character is available. |
|
| 68. |
Which method of character stream class returns the numbers of characters successfully read starting at count?(a) int Read()(b) int Read(char[] buffer, int index, int count)(c) int ReadBlock(char[ ] buffer, int index, int count)(d) none of the mentioned |
|
Answer» The correct answer is (b) int Read(char[] buffer, int index, int count) The explanation is: Attempts to read the count characters into buffer starting at buffer[count], returning the number of characters successfully read. |
|
| 69. |
Which among the following classes are used to perform the character based file operations?(a) StreamReader(b) InputReaderWriter(c) OutputStream(d) All of the mentioned |
|
Answer» The correct option is (a) StreamReader For explanation: In general, to perform character-based file operations, wrap a FileStream inside a StreamReader or a StreamWriter. These classes automatically convert a byte stream into a character stream, and vice versa. |
|
| 70. |
Which among these access specifiers should be used for main() method?(a) private(b) public(c) protected(d) none of the mentioned |
|
Answer» Correct choice is (b) public To explain I would say: main() method must be specified public as it called by Csharp run time system outside of the program, by default main is private in nature if no access specifier is used. |
|
| 71. |
Which of the following statements are incorrect?(a) public members of class can be accessed by any code in the program(b) private members of class can only be accessed by other members of the class(c) private members of class can be inherited by a subclass, and become protected members in subclass(d) protected members of a class can be inherited by a subclass, and become private members of the subclass |
|
Answer» The correct option is (c) private members of class can be inherited by a subclass, and become protected members in subclass The best I can explain: private members of a class cannot be inherited by a subclass. |
|
| 72. |
Which of these access specifiers must be used for class so that it can be inherited by another subclass?(a) public(b) private(c) both public & private(d) none of the mentioned |
|
Answer» The correct choice is (a) public The explanation: None. |
|
| 73. |
Which of these is used as default for a member of a class if no access specifier is used for it?(a) private(b) public(c) protected internal(d) protected |
|
Answer» Correct choice is (a) private The explanation: None. |
|