Chapter 1 provides an introduction to C# programming language, covering its definition, history, development environment setup, and the structure of a basic C# program, including namespaces, classes, the main method, and the compilation process.
Multiple Choice Questions (MCQs)
Section 1: What is C#?
What type of language is C#? a) Functional Programming Language b) Object-Oriented Programming Language c) Procedural Programming Language d) Logic Programming Language
Which of the following features is C# primarily known for? a) Multithreading b) Type safety c) Dynamic typing d) Procedural syntax
C# was developed by which company? a) Sun Microsystems b) Microsoft c) Apple d) Oracle
C# is a part of which framework? a) .NET Framework b) JDK c) Node.js d) Django
Which of the following is NOT a key feature of C#? a) Strong typing b) Garbage collection c) Memory management d) Interpreted language
C# code can be run on which of the following platforms? a) Windows only b) Linux only c) macOS only d) Cross-platform (Windows, Linux, macOS)
Section 2: History of C#
Who is credited with the creation of C#? a) James Gosling b) Anders Hejlsberg c) Linus Torvalds d) Rasmus Lerdorf
When was C# officially released? a) 1999 b) 2000 c) 2002 d) 2005
C# was designed as a successor to which language? a) Java b) C++ c) Visual Basic d) C
What year was C# added to the .NET Framework? a) 2000 b) 2002 c) 2005 d) 2010
Which version of C# introduced support for LINQ (Language Integrated Query)? a) C# 1.0 b) C# 2.0 c) C# 3.0 d) C# 4.0
C# 7.0 introduced which of the following? a) Pattern matching b) Asynchronous programming c) Out variables d) LINQ
Section 3: Setting up C# Development Environment
Which IDE is recommended for C# development on Windows? a) IntelliJ IDEA b) Visual Studio c) Eclipse d) PyCharm
Which of the following is a lightweight code editor suitable for C# development? a) Sublime Text b) Visual Studio Code c) Notepad++ d) Xcode
What is the first step in setting up a C# development environment in Visual Studio? a) Install C# runtime b) Create a new C# project c) Install Visual Studio d) Configure a Git repository
Which of the following is required to run C# applications on Linux? a) Mono b) JDK c) Node.js d) Python
Which version of Visual Studio is free to use for individual developers and small teams? a) Visual Studio Express b) Visual Studio Professional c) Visual Studio Enterprise d) Visual Studio Code
To run C# code in Visual Studio Code, which extension is necessary? a) Python b) C# for Visual Studio Code c) .NET Core d) Java
Section 4: Structure of a C# Program
What is the purpose of a namespace in C#? a) To define data types b) To define a scope for variables c) To organize code into logical groups d) To define the entry point of a program
In C#, which keyword is used to define a class? a) function b) class c) struct d) object
Which method in C# is the entry point of a program? a) start() b) execute() c) main() d) begin()
What type of value must the main method in C# return? a) string b) void c) int d) bool
The following line of code is an example of: namespace HelloWorld { class Program { static void Main() { Console.WriteLine("Hello World!"); } } a) A function definition b) A C# class definition c) A C# namespace definition d) A loop
In C#, what keyword is used to define the entry point of a program? a) static b) public c) private d) main
What is the correct syntax to print “Hello, World!” in C#? a) Console.WriteLine("Hello, World!"); b) Print("Hello, World!"); c) System.out.println("Hello, World!"); d) Write("Hello, World!");
The Main method in C# is often defined as static void Main(). What does the static keyword indicate? a) The method can be called without creating an instance of the class b) The method is private c) The method can return a value d) The method is accessible only from the main class
Section 5: Compilation Process
What is the first step in the C# compilation process? a) Bytecode compilation b) Source code conversion to Intermediate Language (IL) c) Executing the code d) Running unit tests
The C# compiler generates which file extension after compiling a program? a) .exe b) .dll c) .obj d) .cs
In C#, what tool is used to compile and run a program from the command line? a) .NET Core CLI b) GCC c) Visual Studio d) Python CLI
Which component in the C# compilation process is responsible for converting the Intermediate Language (IL) code to native machine code? a) The C# compiler b) The JIT (Just-In-Time) compiler c) The CLR (Common Language Runtime) d) The IDE
Answer Key
Qno
Answer
1
b) Object-Oriented Programming Language
2
b) Type safety
3
b) Microsoft
4
a) .NET Framework
5
d) Interpreted language
6
d) Cross-platform (Windows, Linux, macOS)
7
b) Anders Hejlsberg
8
c) 2002
9
b) C++
10
b) 2002
11
c) C# 3.0
12
c) Out variables
13
b) Visual Studio
14
b) Visual Studio Code
15
c) Install Visual Studio
16
a) Mono
17
a) Visual Studio Express
18
b) C# for Visual Studio Code
19
c) To organize code into logical groups
20
b) class
21
c) main()
22
b) void
23
b) A C# class definition
24
a) static
25
a) Console.WriteLine("Hello, World!");
26
a) The method can be called without creating an instance of the class
27
b) Source code conversion to Intermediate Language (IL)