0% found this document useful (0 votes)
10 views3 pages

Untitled Document

The document contains a series of multiple-choice questions and answers related to C# programming concepts. Key topics include the entry point of a C# console application, the base class of all types in .NET, nullable integers, resource management, access modifiers, ADO.NET methods, and the purpose of the 'using' statement. Each question is followed by the correct answer and a brief explanation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Untitled Document

The document contains a series of multiple-choice questions and answers related to C# programming concepts. Key topics include the entry point of a C# console application, the base class of all types in .NET, nullable integers, resource management, access modifiers, ADO.NET methods, and the purpose of the 'using' statement. Each question is followed by the correct answer and a brief explanation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1. Which of the following is the entry point of a C# console application?

A) MainForm()​
B) Start()​
C) static void Main()​
D) Run()

Answer: C) static void Main()

Explanation: In a C# console application, the static void Main() method is the


default entry point. It can optionally take arguments like string[] args.

2. What is the base class of all types in .NET?

A) ValueType​
B) Object​
C) System​
D) Type

Answer: B) Object

Explanation: All types in .NET, including value types and reference types, derive from the
System.Object class.

3. Which of the following correctly declares a nullable integer in C#?

A) int nullableInt;​
B) nullable int i;​
C) int? i;​
D) Int i = null;

Answer: C) int? i;

Explanation: In C#, int? is the shorthand for Nullable<int>, allowing the variable to
hold null.

4. Which method is used to release unmanaged resources in .NET?


A) Dispose()​
B) Finalize()​
C) Close()​
D) Shutdown()

Answer: A) Dispose()

Explanation: Dispose() is part of the IDisposable interface and is used to explicitly


release unmanaged resources.

5. Which keyword is used to define an abstract class in C#?

A) virtual​
B) static​
C) abstract​
D) override

Answer: C) abstract

Explanation: abstract is used to declare a class that cannot be instantiated and may
contain abstract methods.

6. What is the default access modifier for a class in C#?

A) private​
B) protected​
C) internal​
D) public

Answer: C) internal

Explanation: By default, classes have internal access, meaning they are accessible
only within the same assembly.

7. Which method in ADO.NET is used to execute a SELECT query and


return a DataReader?

A) ExecuteScalar()​
B) ExecuteReader()​
C) ExecuteNonQuery()​
D) ExecuteQuery()

Answer: B) ExecuteReader()

Explanation: ExecuteReader() returns a DataReader object to read data in a


forward-only stream.

8. Which ADO.NET object is used for disconnected data access?

A) DataReader​
B) SqlCommand​
C) SqlConnection​
D) DataSet

Answer: D) DataSet

Explanation: DataSet stores data in memory and supports disconnected data access.

9. What is the purpose of the "using" statement in C#?

A) To import namespaces​
B) To define asynchronous code​
C) To handle exceptions​
D) To create generics

Answer: A) To import namespaces

Explanation: The using statement is primarily used to include namespaces, though it is


also used to ensure resource disposal.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy