2024 APDB101 MajorTheoryTest2 QuestionPaper
2024 APDB101 MajorTheoryTest2 QuestionPaper
INSTRUCTIONS:
On the answer sheet, write only the letter (A, B, C, or D) that best corresponds to the most
appropriate answer for each of the multiple-choice questions from 1.1 to 1.15 below.
1.2 What is the name of the IDE to develop Windows Forms Applications in C#?
A. Visual Code
B. Visio
C. Visual Basic
D. Visual Studio
1.3 Which of the following methods reads a single line of text from the stream and returns
null when the end of the file is reached?
A. ReadToEnd()
B. Close()
C. new StreamReader()
D. ReadLine()
1.4 Which of the following methods reads all the text until the end of the stream?
A. Close()
B. ReadLine()
C. ReadToEnd()
D. new StreamReader()
1.5 Which of the following automatically calls the Close() method for a text file stream after
the execution is completed?
A. None of these options are correct
B. try..catch
C. while()
D. using()
1.6 Which stream class provides methods for writing lines of text and sequences of
characters to a text file?
A. StreamReader
B. StreamRead
C. StreamWrite
D. StreamWriter
1.8 Which of the following statement(s) correctly describes the properties of an array?
1.9 A variable that is used to store the length of an array must be of type __________.
A. string
B. int
C. double
D. class
1.10 Which of the following array declarations will store the highest temperature for
1.11 How many elements are allocated by the following array declaration?
A. 32
B. 3
C. 4
D. 2
1.12 For an array of 10 elements, the highest index is __________.
A. 10
B. 9
C. 11
D. 2
Which of the following statements will double the value stored in anArray[2]?
A. anArray[2] *= 2;
B. anArray = anArray * 2;
C. anArray[2] = anArray[5] * 2;
D. anArray[2] *= anArray[2] * 2;
Assume that the following DUT student results for Semester 2 are contained in the Text File
StudentResults.txt for some of the students registered for APDB101:
Figure 1
You are required to examine and complete the C#.NET button/driver code below that uses the
MT1, MT2, and Quiz1 marks stored in the StudentResults.txt text file to calculate the average
mark for each student and determine whether the student has passed or failed. The student will
pass if he/she obtained the average mark of 50 and above. Display the student number, MT1
mark, MT2 mark, Quiz1 mark, average mark, and result, each separated by a tab (as shown in
Figure 1).
Driver code
private void Button1_Click(object sender, EventArgs e)
{
string lineRec = "";
double average = 0;
2.1_____Results; [1mark]
using (file)
{
2.4 _______ = file.ReadLine(); [1 mark]
Examine the following C# code and answer the questions (3.1 to 3.6 ) below:
Figure 2