Preview Questions

1.4. Preview Questions#

Complete these questions before class to prepare for the chapter. Use the dropdowns to check your answers.

1.4.1. True or False#

1. C# is a compiled, statically-typed language.

Answer

True — C# code is compiled to IL then JIT-compiled at runtime.

2. The dotnet run command compiles and executes a C# project in one step.

Answer

Truedotnet run calls the compiler then runs the output automatically.

3. A namespace in C# is used to execute code at program startup.

Answer

False — A namespace organizes related classes; code runs from Main.

4. In C#, code blocks are delimited by indentation (like Python).

Answer

False — C# uses curly braces {} to delimit code blocks.

5. Visual Studio Code requires a C# extension to provide IntelliSense support.

Answer

True — The C# Dev Kit extension adds language support including IntelliSense.

6. A single .csproj project can contain multiple .cs files but only one entry point (Main() method).

Answer

True — A project can have many .cs files (each defining classes or helpers), but only one file may serve as the entry point with a Main() method or top-level statements.

1.4.2. Multiple Choice#

1. What is the entry point method of a C# console application?

a) Start()
b) Init()
c) Main()
d) Run()

Answer

c) Main()Main() is where the CLR begins execution.

2. Which command creates a new C# console project?

a) dotnet init
b) dotnet new console
c) dotnet create
d) dotnet build

Answer

b) dotnet new consoledotnet new console scaffolds a new console application.

3. In C#, which keyword groups related classes under a common name?

a) package
b) module
c) namespace
d) library

Answer

c) namespacenamespace is the C# equivalent of Java packages or Python modules.

4. Which statement outputs text to the console?

a) print(“Hello”)
b) Console.Print(“Hello”)
c) Console.WriteLine(“Hello”)
d) Output(“Hello”)

Answer

c) Console.WriteLine(“Hello”)Console.WriteLine() writes a line to standard output.

5. What file extension is used for C# source files?

a) .net
b) .csharp
c) .cs
d) .cpp

Answer

c) .cs — C# source files use the .cs extension.

Footnotes