Explore topic-wise MCQs in C Sharp Programming.

This section includes 14 Mcqs, each offering curated multiple-choice questions to sharpen your C Sharp Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

What would be the output of given code snippet?

A. 0 6 7 8
B. 0 5 7 9
C. 5 9 0 7
D. 0 5 7 12
Answer» E.
2.

What will be the output of the given code snippet?

A. sharp
B. csharp
C. c
D. sharp c
Answer» C. c
3.

What will be the output of given code snippet?

A. hello 6world
B. hello good world
C. hello goodworld
D. hello good world
Answer» D. hello good world
4.

Choose the output for the given set of code:

A. This will generate an exception
B. 0
C. Compile time error
D. This will generate an exceptionAttempted to Divide by Zero
Answer» B. 0
5.

What would be the output for following input from the console as a character?

A. Compile time error
B. Code run successfully prints nothing on console
C. Code runs successfully prints input on console
D. Run time error
Answer» E.
6.

Choose the output for the following set of code?

A. Compile time error
B. Runs successfully does not print anything
C. Runs successfully, ask for input and hence displays the result
D. Syntax Error
Answer» D. Syntax Error
7.

In the given constructor declaration for character based file operation what does ‘path’ and ‘bool specifies?StreamWriter(string path, bool append)

A. the name of the file to open
B. specifies the full path of file
C. if append is true, the file is appended to the end of the existing file
D. all of the mentioned
Answer» E.
8.

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» B. int read()
9.

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

A. Read()
B. ReadByte()
C. ReadLine()
D. Readkey()
Answer» B. ReadByte()
10.

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» E.
11.

Which among the following attempts to read up to count bytes into buffer starting at buffer[offset], returning the number of bytes successfully read?

A. int ReadByte()
B. int Read(byte[] buffer ,int offset ,int count)
C. Void WriteByte(byte value)
D. None of the mentioned
Answer» C. Void WriteByte(byte value)
12.

Which among the following is the correct form of applying an attribute?

A. <Serializable()>class sample { }
B. (Serializable())class sample { }
C. [Serializable()] class sample { }
D. None of the mentioned
Answer» D. None of the mentioned
13.

The correct way to apply the custom attribute called Employer which receives two arguements – name of the employee and employeeid is?

A. Custom attribute can be applied to an assembly
B. [assembly : Employer(“Ankit”,employeeid.one)].
C. [ Employer(“Ankit”, employeeid.second)] class employee{}
D. All of the mentioned
Answer» E.
14.

The [Serializable()] attributes gets inspected at:

A. compile time
B. run time
C. design time
D. linking time
Answer» C. design time