NEW
Font size
WorksheetsVariables
Total questions: 10
Worksheet time: 5mins
What is the purpose of reading input from command-line arguments in a C# program?
To get user input when the program starts
To display output on the console
To create a graphical user interface
To connect to a database
Which method is used to convert a value type argument into an integer?
ToInt()
Convert.ToInt32()
String.ToNumber()
ParseInt()
Which keyword is used to define a class in C#?
class
struct
object
method
How do you check if a person is eligible for voting in the provided code?
if (int.Parse(args[1])>18)
if (args[2]=='F')
if (args.Length>0)
if (args[0]>18)
Which keyword is used to declare a constant variable in C#?
const
static
readonly
final
Which statement about readonly is correct?
It must be assigned at compile time
It can be assigned only inside the constructor
It allows modification anywhere
It is same as const
Which method is used to compare the values of two strings in C# for equality?
Equals()
CompareTo()
Match()
Compare()
const float PI = 3.14f;
Console.WriteLine(PI * 2);
6.14
6.28
3.14
compile-error
class A {
public static int count = 1;
}
class Program {
static void Main() {
A.count++;
A.count++;
Console.WriteLine(A.count);
}
}
1
2
3
Runtime error
int x = Convert.ToInt32("15");
int y = int.Parse("5");
Console.WriteLine(x + y);
155
10
20
Error
