CSharp MCQ Quiz Part 1

CSharp MCQ

This CSharp MCQ Quiz contains few questions as a free online practice test.

1. Static classes can be instantiated.

a) True
b) False

2. Static constructors are called automatically before first instance of the class is created.

a) True
b) False

3. Consider the following code snippet and choose false statement among the options.

private int myInt = 20;
public int MyInt
{
private get
{
return myInt;
}
protected set
{
myInt = value;
}

}

a) We can specify accessibility (private, protected, etc.) for accessors of a property that is different from the property itself.
b) We can specify accessibility for both the accessors

4. In context of exception handling can we write a try block without catch block but a finally block?

a) True
b) False

5. Can a specific exception handler catch generic exception? What will be the output of
the following code?

static void Main(string[] args)
{
try
{
throw new Exception(“Some issue”);
}
catch (OutOfMemoryException e)
{
Console.WriteLine(“Memory issue: ” + e.Message);
}
catch (Exception e)
{
Console.WriteLine(“Generic issue: ” + e.Message);
}
}

a) Memory issue: Some issue
b) Generic issue: Some issue
c) Program will crash

6. Which of the following statements is correct?

a) throw new Exception(“some error”);
b) throw Exeption(“some error”);

7. Which of the following statements is true in context of global variable @@ERROR in context of Stored Procedures?

a) It will return 1 if there is an error in any T-SQL statement
b) It is reset after each statement
c) It could be error prone to depend on this and hence TRY…CATCH blocks can be used.

8. Which of the following statements are true?

a. In context of ADO.NET a connection pool is created for each unique connection string
b. Number of connections (Maximum allowed and minimum to be maintained) can be specified using “Max Pool Size” and “Min Pool Size”.
c. Once created, connection pools are not destroyed until the active process ends.

9. Which of the following statements are true?

a. A trigger can be fired when any INSERT, UPDATE or DELETE SQL command is executed.
b. SQL Server manages records recently inserted/deleted and these are sometimes referred as Magic Tables

10. DataRowState enumeration has flags like Added and Deleted to specify if a row is
added and deleted respectively.

a) True
b) False

11. Which of the following statements are true?

a. Clone method of DataSet copies the structure of the DataSet.
b. Copy method of the DataSet copies structure and data of the DataSet.
c. AcceptChanges methods commits all changes made to the DataSet.
d. GetXml method of DataSet gets the XML representation of the data stored in the DataSet.

13. Which of the following are SQL Server in-process specific extensions to ADO.NET?

a. SqlContext
b. SqlPipe
c. SqlTriggerContext
d. SqlDataRecord
e. All of the above

15. Which of the following statements are true?

a. XML with correct syntax is “Well Formed” XML.
b. XML validated against a DTD is “Valid” XML.

16. A Well Formed XML has correct XML syntax, these which of the following?

a. XML documents must have a root element
b. XML elements must have a closing tag
c. XML tags are case sensitive
d. elements must be properly nested
e. attribute values must be quoted

17. Which of the following are among few important classes in data Access Application Blocks?

a. Databasefactory
b. Database
c. GenericDatabase

18. StringBuilder represents mutable string of characters.

a. True
b. False

19. Which class serializes and deserializes objects into and from XML documents?

a. XMLConverter
b. Serialize
c. XmlSerializer

20. In context of threading – methods of InterLocked class help protect against errors that can occur when the scheduler switches contexts while a thread is updating a variable that can be accessed by other threads, or when two threads are executing concurrently on separate processors.

a. True
b. False

21. Which of the following are available classes for thread synchronization?

a. Mutex
b. Monitor
c. InterLocked
d. AutoResetEvent