Unit 1: Introduction to .NET and C# - Practice Quiz

CSE253 — .Net Programming 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is .NET primarily used for?

Introduction to .NET and its features Easy
A. Developing different types of applications
B. Designing only printed documents
C. Managing only computer hardware
D. Creating only spreadsheet formulas

2 Which feature allows .NET applications to run on multiple operating systems?

Introduction to .NET and its features Easy
A. Single-user access
B. Cross-platform support
C. Manual memory allocation
D. Fixed hardware support

3 Which platform was originally designed mainly for Windows applications?

Difference between .NET Framework, .NET Core and .NET Easy
A. Modern .NET
B. .NET CLI
C. .NET Core
D. .NET Framework

4 What is a major characteristic of .NET Core?

Difference between .NET Framework, .NET Core and .NET Easy
A. It is used only for databases
B. It supports multiple operating systems
C. It requires no programming language
D. It works only with Windows XP

5 What does the .NET SDK provide?

.NET SDK and Runtime Easy
A. Tools for building applications
B. Only files for running applications
C. Only database backup files
D. Only desktop wallpaper tools

6 What is the main purpose of the .NET Runtime?

.NET SDK and Runtime Easy
A. Running .NET applications
B. Installing operating systems
C. Editing source code only
D. Creating project templates

7 What does CLR stand for?

Common Language Runtime (CLR) Easy
A. Computer Language Register
B. Code Loading Repository
C. Common Link Resource
D. Common Language Runtime

8 Which service is commonly provided by the CLR?

Common Language Runtime (CLR) Easy
A. Internet connection installation
B. Automatic memory management
C. Keyboard layout printing
D. Physical disk manufacturing

9 What is the .NET Class Library?

.NET Class Library Easy
A. A list of internet websites
B. A collection of computer drivers
C. A tool for formatting disks
D. A collection of reusable classes

10 Which task can be supported by classes in the .NET Class Library?

.NET Class Library Easy
A. Replacing computer hardware
B. Reading and writing files
C. Changing electrical voltage
D. Manufacturing a processor

11 Which application is a full-featured IDE for .NET development?

Setting up development environment using Visual Studio and VS Code Easy
A. Paint
B. File Explorer
C. Visual Studio
D. Calculator

12 What is Visual Studio Code commonly described as?

Setting up development environment using Visual Studio and VS Code Easy
A. A lightweight source code editor
B. A computer operating system
C. A database server platform
D. A physical programming device

13 Which command creates a new .NET project?

Introduction to .NET CLI and commonly used CLI commands Easy
A. dotnet start
B. dotnet new
C. dotnet open
D. dotnet make

14 Which command builds a .NET project?

Introduction to .NET CLI and commonly used CLI commands Easy
A. dotnet create
B. dotnet package
C. dotnet compile
D. dotnet build

15 Which file commonly contains configuration for a .NET project?

Project structure in .NET applications Easy
A. A folder with a .hardware extension
B. A project file with a .csproj extension
C. A text file with a .photo extension
D. A document with a .music extension

16 What is NuGet used for in .NET development?

NuGet Package Manager Easy
A. Creating operating system accounts
B. Managing computer power settings
C. Managing reusable software packages
D. Designing physical computer parts

17 Which command runs a .NET application from its project folder?

Building and executing .NET applications Easy
A. dotnet run
B. dotnet launch
C. dotnet perform
D. dotnet execute

18 What type of programming language is C#?

Introduction to C# Easy
A. A general-purpose programming language
B. A hardware description language
C. A markup language for web pages
D. A query language for tables only

19 Which method is traditionally used as the starting point of a C# console program?

C# program structure Easy
A. Main
B. Begin
C. Start
D. Launch

20 What is Git mainly used for?

Introduction to Git and GitHub for source code management Easy
A. Managing screen brightness
B. Tracking changes in source code
C. Designing presentation slides
D. Compiling computer hardware

21 A development team wants to share business logic between applications running on Windows, Linux, and macOS. Which .NET feature most directly supports this requirement?

Introduction to .NET and its features Medium
A. Language-specific memory management
B. Windows-only desktop integration
C. Registry-based configuration support
D. Cross-platform application support

22 A C# application creates many temporary objects while processing requests. Which .NET feature automatically reclaims memory occupied by objects that are no longer reachable?

Introduction to .NET and its features Medium
A. Garbage collection
B. Just-in-time debugging
C. Assembly signing
D. Package restoration

23 A company is starting a new cross-platform web service and wants the currently unified, actively developed .NET platform. Which platform should it choose?

Difference between .NET Framework, .NET Core and .NET Medium
A. ASP.NET Web Forms
B. .NET Framework 4.8
C. .NET Core 2.1
D. Modern .NET

24 An existing application depends heavily on ASP.NET Web Forms and Windows-specific .NET Framework libraries. Which migration decision is most appropriate initially?

Difference between .NET Framework, .NET Core and .NET Medium
A. Keep it on .NET Framework while assessing dependencies
B. Move it directly to .NET without compatibility testing
C. Replace the runtime with only the .NET SDK
D. Compile it as a Linux-native application immediately

25 A production server only needs to execute a framework-dependent .NET application and will never compile source code. What is the minimum appropriate installation?

.NET SDK and Runtime Medium
A. The complete .NET SDK
B. The NuGet command-line client
C. The matching .NET Runtime
D. The Visual Studio IDE

26 A developer can run an existing .NET application but receives an error that the dotnet new command is unavailable. What is the most likely cause?

.NET SDK and Runtime Medium
A. The application uses garbage collection
B. Only the .NET Runtime is installed
C. The project contains no namespace
D. Only the .NET SDK is installed

27 A C# project is compiled successfully, but its methods have not yet been translated into native processor instructions. What form is the compiled code typically in?

Common Language Runtime (CLR) Medium
A. Native machine instructions
B. C# source statements
C. Common Intermediate Language
D. NuGet package metadata

28 When a managed .NET method is called for the first time, which CLR component commonly translates its intermediate code into native machine code?

Common Language Runtime (CLR) Medium
A. C# preprocessor
B. Garbage collector
C. Just-in-time compiler
D. NuGet resolver

29 A developer needs to read a text file without writing operating-system-specific file access code. Which .NET class library type is the most appropriate starting point?

.NET Class Library Medium
A. System.Random
B. System.Math
C. System.IO.File
D. System.Console

30 A developer is configuring VS Code for C# development on Linux. Which combination provides the essential compiler tools and editor language support?

Setting up development environment using Visual Studio and VS Code Medium
A. NuGet client and a theme extension
B. Visual Studio Build Tools and IIS
C. .NET Runtime and a Git extension
D. .NET SDK and a C# extension

31 A developer wants to create a console project named InventoryApp in a new directory. Which command performs this task?

Introduction to .NET CLI and commonly used CLI commands Medium
A. dotnet run console -n InventoryApp
B. dotnet new console -n InventoryApp
C. dotnet build console -n InventoryApp
D. dotnet add console -n InventoryApp

32 A cloned project references several NuGet packages, but the package files are not available locally. Which command explicitly downloads the required dependencies?

Introduction to .NET CLI and commonly used CLI commands Medium
A. dotnet clean
B. dotnet restore
C. dotnet publish
D. dotnet format

33 A developer needs to change a console application's target framework and enable nullable reference type analysis. Which file should be edited?

Project structure in .NET applications Medium
A. The .csproj file
B. The Program.cs file
C. The launchSettings.json file
D. The .sln file

34 After compiling a .NET project, a developer sees bin and obj directories. Which description correctly distinguishes them?

Project structure in .NET applications Medium
A. bin holds packages, while obj holds Git history
B. bin holds final outputs, while obj holds intermediate files
C. bin holds settings, while obj holds solution files
D. bin holds source files, while obj holds final outputs

35 A project requires the Newtonsoft.Json library, and the developer wants the dependency recorded in the project file. Which command should be used?

NuGet Package Manager Medium
A. dotnet build package Newtonsoft.Json
B. dotnet reference package Newtonsoft.Json
C. dotnet restore package Newtonsoft.Json
D. dotnet add package Newtonsoft.Json

36 Two developers restore the same project and should receive the same dependency graph when package versions have not changed. Which generated file helps NuGet use the resolved dependency information?

NuGet Package Manager Medium
A. Properties/launchSettings.json
B. bin/Debug/app.dll
C. obj/project.assets.json
D. .git/HEAD

37 A developer has already built a project and wants to run it without triggering another build. Which command is most appropriate?

Building and executing .NET applications Medium
A. dotnet restore --no-build
B. dotnet run --no-build
C. dotnet execute --cached
D. dotnet build --no-run

38 A C# variable declared as int count = 5; must later store the value 5.75. Which change best preserves the fractional part?

Introduction to C# Medium
A. Keep int and cast the value
B. Change the type to double
C. Change the type to bool
D. Keep int and call ToString()

39 Consider a traditional C# console application containing several classes. Which method signature can serve as its entry point?

C# program structure Medium
A. private void Main(int args)
B. public void Start(string[] args)
C. static int Run(object args)
D. static void Main(string[] args)

40 A developer has modified Program.cs and wants to create a local Git snapshot before sending it to GitHub. Which command sequence is correct?

Introduction to Git and GitHub for source code management Medium
A. git push Program.cs followed by git add -m "Update program"
B. git add Program.cs followed by git commit -m "Update program"
C. git clone Program.cs followed by git commit "Update program"
D. git pull Program.cs followed by git stage "Update program"

41 A team needs to run the same application on Windows and Linux while preserving managed memory, type safety, asynchronous programming support, and access to a large standard library. Which .NET characteristic most directly enables this combination?

Introduction to .NET and its features Hard
A. Platform-specific native compilation
B. Managed execution over a cross-platform runtime
C. A shared Windows registry configuration
D. Use of only interpreted C# code

42 An existing ASP.NET application depends on System.Web and must remain hosted on IIS in a Windows-only environment. Which migration choice has the lowest compatibility risk?

Difference between .NET Framework, .NET Core and .NET Hard
A. Replace IIS with the .NET CLI runtime
B. Port the application to .NET Core using System.Web
C. Keep it on a compatible version of .NET Framework
D. Move directly to .NET 8 without code changes

43 A deployment server must execute a framework-dependent application but must not compile, restore, or create new projects. Which installation is normally sufficient?

.NET SDK and Runtime Hard
A. Only the C# compiler package
B. Only the NuGet client
C. The matching .NET SDK
D. The matching .NET Runtime

44 A C# method allocates objects repeatedly, and no explicit deallocation occurs. Which CLR responsibility most directly prevents unreachable managed objects from remaining indefinitely in memory?

Common Language Runtime (CLR) Hard
A. Garbage collection
B. Source-code compilation
C. NuGet package restoration
D. Assembly version binding

45 Two libraries written in different .NET languages exchange objects through public methods. Which CLR feature most directly makes this interoperability possible?

Common Language Runtime (CLR) Hard
A. A package-locking algorithm
B. A common type system
C. A shared Git repository
D. A platform-specific user interface

46 A project targets a modern .NET version and needs file access, collections, JSON serialization, and networking. Why can it use these APIs without implementing operating-system-specific versions of each feature?

.NET Class Library Hard
A. The CLR converts all operating-system calls into SQL
B. GitHub supplies the APIs during program execution
C. The compiler embeds every API into each source file
D. The .NET Class Library exposes standardized reusable APIs

47 A developer can open a C# file in VS Code but receives unresolved project references and cannot run dotnet build. Which diagnosis is most accurate?

Setting up development environment using Visual Studio and VS Code Hard
A. C# projects cannot be built outside Visual Studio
B. The editor is installed, but the required SDK or extensions may be missing
C. VS Code itself includes the complete .NET SDK
D. The project must be converted to a Visual Studio solution

48 A Visual Studio solution opens successfully, but a web project lacks debugging support and cannot start with its expected profile. What is the most likely setup issue?

Setting up development environment using Visual Studio and VS Code Hard
A. The required Visual Studio workload or project components were not installed
B. The solution must be stored inside a GitHub repository
C. The project file must be renamed to startup.cs
D. The project needs a second Main method

49 A developer wants to verify that a project compiles without producing output binaries in its normal output location. Which command best matches that intent?

Introduction to .NET CLI and commonly used CLI commands Hard
A. dotnet clean --no-build
B. dotnet run --no-build
C. dotnet build --no-restore
D. dotnet restore --no-build

50 A CI job must run an already-restored project and fail if a build is implicitly required. Which command expresses that requirement?

Introduction to .NET CLI and commonly used CLI commands Hard
A. dotnet restore --no-cache
B. dotnet clean --no-restore
C. dotnet run --no-build
D. dotnet new --no-build

51 A project file contains a PackageReference, and the project has a Program.cs file but no manually maintained list of every source file. Which explanation is correct for modern SDK-style projects?

Project structure in .NET applications Hard
A. The CLR discovers source files at runtime
B. The project file excludes all source files by default
C. NuGet generates source files during every compilation
D. The SDK implicitly includes conventional source files

52 A project targets net8.0 and references a package that supports only net6.0. What is the most important compatibility question before assuming the reference will work?

Project structure in .NET applications Hard
A. Whether GitHub has indexed the package source
B. Whether the package has compatible assets or a compatible target framework
C. Whether the package name contains the target framework
D. Whether Program.cs is placed before the project file

53 A package reference is added to a project file, but a clean build on another machine fails because the package cannot be found. Which action is normally required before compilation?

NuGet Package Manager Hard
A. Run git merge
B. Rename the package reference
C. Run package restore
D. Install the CLR manually

54 A project uses a package version range, and two developers restore it at different times and receive different transitive dependency versions. Which practice most directly improves reproducibility?

NuGet Package Manager Hard
A. Reference every package only by its display name
B. Use a lock file and controlled package sources
C. Delete the project file before restoring
D. Compile exclusively through Visual Studio

55 A framework-dependent application is built on one machine and copied to another machine that lacks the required target runtime. What is the expected result when it is executed?

Building and executing .NET applications Hard
A. The application automatically bundles the missing runtime
B. The CLR silently recompiles it for the installed runtime
C. NuGet restores the runtime during application startup
D. The application usually fails because the required runtime is unavailable

56 A team wants a deployment artifact that can run on a target machine without requiring that machine to have the corresponding .NET runtime installed. Which approach is appropriate?

Building and executing .NET applications Hard
A. Use dotnet restore only
B. Use a self-contained deployment
C. Use a framework-dependent deployment
D. Publish only the project file

57 A method receives a string parameter and assigns a new string to that parameter. The caller's variable still refers to the original string. Which language behavior explains this result?

Introduction to C# Hard
A. The CLR forbids reassignment of string variables
B. Strings are mutable reference objects
C. Parameters are passed by value unless specified otherwise
D. C# converts all parameters into value types

58 A nullable reference type warning appears when a value obtained from configuration is assigned to a non-nullable string. What does the warning primarily indicate?

Introduction to C# Hard
A. The value is automatically converted to a value type
B. The compiler cannot prove that the value is non-null
C. The runtime has already thrown a null exception
D. The string is guaranteed to be empty

59 In a modern console project, a developer adds top-level statements and also declares a conventional static void Main() method. The project fails to compile. What is the most likely reason?

C# program structure Hard
A. A console project cannot contain methods
B. Top-level statements generate an entry point, creating a conflict
C. Top-level statements require a namespace named Main
D. The CLR requires two entry points for console applications

60 A file-scoped namespace declaration is followed by a second namespace declaration in the same file. Why is this invalid?

C# program structure Hard
A. The namespace must be declared after all type declarations
B. Namespaces cannot contain classes in C#
C. A file-scoped namespace must be the only namespace declaration in its file
D. File-scoped namespaces can appear only in project files