july 2019 question paper Flashcards

1
Q

What data type is suitable for storing a child’s age in a Day Care School Application?

A

int, single, or byte (any whole number type).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What data type should be used to store school fees payment?

A

float, double, or decimal (floating point types).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are two properties of a string in C#?

A

Length and Char[].

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name three ways to initialize a string variable in C#.

A

Assigning string literals

Assigning the value of another string

Assigning the return value of a method that returns a string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does the Equals() method of a string do?

A

Compares two strings and returns true if they are identical.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does CompareTo() return when comparing two strings?

A

An integer: -1, 0, or 1 depending on lexicographical order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What type of loop checks the condition before execution?

A

for loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What type of loop checks the condition after execution?

A

do-while loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a nested loop?

A

A loop inside another loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the ticket price for a 37-year-old who buys a ticket online, given a 25% discount?

A

Ticket price: 300

Discount: 25% of 300 = 75

Final price: 225.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Write a C# loop that prints multiples of 7 from 1 to 100.

A

for(int k = 7; k <= 100; k += 7) {
Debug.Print(k);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is method overloading?

A

Using multiple methods with the same name but different parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

List three components of a method signature in C#.

A

Number of parameters

Data types of parameters

Order of parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an exception in C#?

A

An error that occurs during program execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you handle exceptions in C#?

A

Using try-catch blocks:

try {
// Code that might throw an exception
} catch(Exception ex) {
MessageBox.Show(ex.Message);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is data persistence?

A

Making data available beyond program execution.

17
Q

What is a disadvantage of using text files for data persistence?

A

Variable-length fields make it difficult to parse data.

18
Q

What does CSV stand for?

A

Comma Separated Values.

19
Q

Name three form events in Visual Studio.

A

Form_Load

Form_Closing

Form_Click.

20
Q

Write a method to compute the area of a circle given its radius.

A

public double ComputeArea(double r) {
const double pi = 3.14159;
return pi * r * r;
}