Worksheets.net fundamentals AG - Module 3
Total questions: 41
Worksheet time: 21mins
Name
Class
Date
1.
Which namespace is used for text file handling in .NET?
a)
System.Text
b)
System.Xml
c)
System.IO
d)
System.Threading
2.
Which method quickly reads the entire content of a text file?
a)
File.ReadLines
b)
File.OpenText
c)
StreamReader.Read
d)
File.ReadAllText
3.
Which class provides line-by-line reading of text files?
a)
FileInfo
b)
StreamWriter
c)
StreamReader
d)
BinaryReader
4.
What is the purpose of File.AppendAllText?
a)
Delete a file
b)
Replace file contents
c)
Create a new file
d)
Append content to an existing file
5.
Which .NET namespace is used for JSON handling?
a)
System.Json
b)
System.Text.Json
c)
Newtonsoft.Json
d)
System.IO.Json
6.
Which method serializes an object to JSON in .NET?
a)
JsonFile.Serialize
b)
Object.ToJson
c)
JsonSerializer.Serialize
d)
JsonSerializer.Write
7.
Which method deserializes JSON back into an object?
a)
JsonSerializer.Deserialize
b)
JsonReader.Read
c)
JsonConvert.Parse
d)
File.ReadAllText
8.
Which namespace is used for working with XML in .NET?
a)
System.Text
b)
System.Xml.Core
c)
System.Xml.Linq
d)
System.Xml.Json
9.
What does serialization mean?
a)
Converting an object to a storable format
b)
Compressing data
c)
Reading from a stream
d)
Encrypting a file
10.
Which formats are common for serialization in .NET?
a)
YAML, HTML, CSS
b)
JSON, XML, Binary
c)
CSV, PDF, PNG
d)
TXT, DOCX, XLS
11.
Which process reconstructs an object from a stored format?
a)
Streaming
b)
Compilation
c)
Parsing
d)
Deserialization
12.
Which library is recommended for modern JSON in .NET?
a)
Newtonsoft.Json
b)
System.IO.Json
c)
System.Text.Json
d)
System.Runtime.Json
13.
Which class is used for XML serialization in .NET?
a)
XmlSerializer
b)
XmlParser
c)
XmlReader
d)
XDocument
14.
Which exception should you handle when deserializing invalid JSON?
a)
IOException
b)
FileNotFoundException
c)
InvalidCastException
d)
JsonException
15.
Which class allows low-level access to files as byte streams?
a)
StreamReader
b)
FileStream
c)
Path
d)
BinaryReader
16.
What does a Stream represent in .NET?
a)
A sequence of bytes
b)
A memory address
c)
A LINQ query
d)
A collection of objects
17.
Which stream is used for storing temporary data in memory?
a)
FileStream
b)
NetworkStream
c)
MemoryStream
d)
StringReader
18.
Which classes are higher-level wrappers for text files?
a)
BinaryWriter
b)
XmlSerializer
c)
FileStream/MemoryStream
d)
StreamReader/StreamWriter
19.
Why use a using block with streams?
a)
Reduces file size
b)
Encrypts data
c)
Ensures automatic disposal
d)
Prevents compilation errors
20.
Which async methods improve scalability with streams?
a)
SaveAsync/LoadAsync
b)
ReadAsync/WriteAsync
c)
Read/Write
d)
Open/Close
21.
What is the role of the Garbage Collector (GC)?
a)
Compile code faster
b)
Free unused memory automatically
c)
Create new objects
d)
Encrypt managed data
22.
Which GC generation handles short-lived objects?
a)
Gen 2
b)
Gen 0
c)
Gen 1
d)
Large Object Heap
23.
Which GC generation is used for long-lived static data?
a)
Gen 1
b)
Gen 0
c)
LOH
d)
Gen 2
24.
Which resources are NOT managed by the GC?
a)
Arrays
b)
Strings
c)
Integers
d)
File handles & DB connections
25.
Which interface is used to release unmanaged resources?
a)
IDisposable
b)
ICloneable
c)
ISerializable
d)
IComparable
26.
What does the Dispose method do?
a)
Reads files
b)
Frees unmanaged resources
c)
Compiles code
d)
Serializes data
27.
Which keyword simplifies calling Dispose()?
a)
lock
b)
using
c)
sealed
d)
async
28.
Which practice is recommended in memory management?
a)
Call GC.Collect() often
b)
Never use IDisposable
c)
Keep large objects always in memory
d)
Avoid GC.Collect()
29.
Which exception might occur if a file path is invalid?
a)
IOException
b)
DivideByZeroException
c)
NullReferenceException
d)
InvalidOperationException
30.
Which format is preferred for modern APIs and microservices?
a)
Binary
b)
XML
c)
JSON
d)
CSV
31.
What happens if you open a file with FileMode.Create?
a)
Opens existing file
b)
Deletes the file
c)
Creates a new file or overwrites
d)
Appends data to file
32.
Which method appends a line to a text file easily?
a)
File.AppendAllText
b)
File.WriteAllLines
c)
FileStream.Write
d)
File.Open
33.
Which class provides LINQ-to-XML features?
a)
XmlDocument
b)
XmlSerializer
c)
XDocument
d)
XmlReader
34.
What happens if you forget to dispose a Stream?
a)
Data is automatically saved
b)
It may leak resources
c)
File is locked forever
d)
Nothing
35.
Which exception is thrown if a file does not exist?
a)
IOException
b)
FileNotFoundException
c)
NullReferenceException
d)
InvalidOperationException
36.
Which type of stream is used to send data over sockets?
a)
FileStream
b)
MemoryStream
c)
NetworkStream
d)
BufferedStream
37.
Which is a benefit of using MemoryStream?
a)
Persistent storage
b)
Temporary in-memory data
c)
Faster disk writes
d)
Replaces FileStream
38.
What does GC.Collect() do?
a)
Starts serialization
b)
Forces garbage collection
c)
Saves memory to disk
d)
Cleans all variables
39.
Why should you avoid GC.Collect() in production?
a)
It causes exceptions
b)
It slows performance
c)
It deletes files
d)
It stops the program
40.
Which block guarantees code execution even after an exception?
a)
finally
b)
using
c)
lock
d)
catch
41.
Which keyword is required to override a base method?
a)
new
b)
override
c)
sealed
d)
static
100 %
