july 2019 question paper Flashcards
What data type is suitable for storing a child’s age in a Day Care School Application?
int, single, or byte (any whole number type).
What data type should be used to store school fees payment?
float, double, or decimal (floating point types).
What are two properties of a string in C#?
Length and Char[].
Name three ways to initialize a string variable in C#.
Assigning string literals
Assigning the value of another string
Assigning the return value of a method that returns a string.
What does the Equals() method of a string do?
Compares two strings and returns true if they are identical.
What does CompareTo() return when comparing two strings?
An integer: -1, 0, or 1 depending on lexicographical order.
What type of loop checks the condition before execution?
for loop.
What type of loop checks the condition after execution?
do-while loop.
What is a nested loop?
A loop inside another loop.
What is the ticket price for a 37-year-old who buys a ticket online, given a 25% discount?
Ticket price: 300
Discount: 25% of 300 = 75
Final price: 225.
Write a C# loop that prints multiples of 7 from 1 to 100.
for(int k = 7; k <= 100; k += 7) {
Debug.Print(k);
}
What is method overloading?
Using multiple methods with the same name but different parameters.
List three components of a method signature in C#.
Number of parameters
Data types of parameters
Order of parameters.
What is an exception in C#?
An error that occurs during program execution.
How do you handle exceptions in C#?
Using try-catch blocks:
try {
// Code that might throw an exception
} catch(Exception ex) {
MessageBox.Show(ex.Message);
}
What is data persistence?
Making data available beyond program execution.
What is a disadvantage of using text files for data persistence?
Variable-length fields make it difficult to parse data.
What does CSV stand for?
Comma Separated Values.
Name three form events in Visual Studio.
Form_Load
Form_Closing
Form_Click.
Write a method to compute the area of a circle given its radius.
public double ComputeArea(double r) {
const double pi = 3.14159;
return pi * r * r;
}