ExamVeda
Login
Home
41
What is the correct syntax to declare a nullable integer variable in C#?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
42
What is the purpose of the 'unchecked' keyword in C#?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
43
What is the output of the following code: Console.WriteLine($"5 + 5 = {5 + 5}");
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
44
What is the correct way to declare and initialize a string variable in C#?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
45
Which of the following is NOT a valid C# data type?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
46
Type of Conversion in which compiler is unable to convert the data type implicitly is?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
47
Choose ".NET class" name from which data type "UInt" is derived?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
48
Syntax for declaration and initialization of data variable is?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
49
What will be the output of the following C# code?
class Program
{
    static void Main(string[] args)
    {
        int i;
        for ( i = 0; i < 5; i++)
        {
 
        }
        Console. WriteLine(i);
        Console. ReadLine();
    }
}
Discuss
Answer & Solution
Answer: Option C
Solution:
The correct answer is C: 5
Here's why:
Let's break down the code step by step:
int i; declares an integer variable named 'i'.
for (i = 0; i < 5; i++) is a for loop. Let's see how it works:
i = 0; This is the initialization part. 'i' starts at 0.
i < 5; This is the condition. The loop continues as long as 'i' is less than 5.
i++; This is the increment. After each loop iteration, 'i' increases by 1.
The loop runs as follows:
i = 0 (0 < 5 is true)
i = 1 (1 < 5 is true)
i = 2 (2 < 5 is true)
i = 3 (3 < 5 is true)
i = 4 (4 < 5 is true)
i = 5 (5 < 5 is false) The loop stops here.
Console.WriteLine(i); This line prints the final value of 'i', which is 5.
Console.ReadLine(); This line just waits for you to press Enter before the program closes (it keeps the console window open so you can see the output).
50
For the following C# code select the relevant solution for conversion of data type.
static void Main(string[] args)
{
    int num1 = 20000;
    int num2 = 50000;
    long total;
    total = num1 + num2;
    Console.WriteLine("Total is : " +total);
    Console.ReadLine();
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board