ExamVeda
Login
Home
61
'Implicit Conversion' follows the order of conversion as per compatibility of data type as:
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
62
What will be the output of the following C# code?
static void Main(string[] args)
{
    string s1 = "Delhi";
    string s2;
    s2 = s1.Insert (6, "Jaipur");
    Console.WriteLine(s2);
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
63
What will be the output of the following C# code?
static void Main(string[] args)
{
    { 
        var dayCode = "MTWFS";
        var daysArray = new List<string>();
        var list = new Dictionary<string, string>
        { {"M", "Monday"}, {"T", "Tuesday"}, {"W", "Wednesday"},
          {"R", "Thursday"}, {"F", "Friday"}, {"S", "Saturday"},
          {"U", "Sunday"}
        };
       for (int i = 0,max = dayCode.Length; i < max; i++)
       {
           var tmp = dayCode[i].ToString();
           if (list.ContainsKey(tmp))
           {
               daysArray.Add(list[tmp]);
            }
       }
       Console.WriteLine(string.Join("\n ", daysArray)); 
 }
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
64
Choose the correct type of variable scope for the following C# defined variables.
class ABC
{
    static int m;
    int n;
    void fun (int x , ref int y, out int z, int[] a)
    {
       int j = 10;
    }
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
65
Which is the String method used to compare two strings with each other?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
66
What will be the output of the following C# code?
static void Main(string[] args)
{
     int i ;
     for (i = 0; i < 5; i++)
     {
         int j = 0;
         j += i; 
         Console. WriteLine(j);
     }
     Console. WriteLine( i * j);
     Console. ReadLine();
}
Discuss
Answer & Solution
Answer: Option C
Solution:
Understanding the Code:
This C# code uses a for loop to repeat a block of code five times.
Inside the loop, a variable j is declared and initialized to 0 in each iteration.
Then, j is updated by adding the current value of i to it (j += i;).
The value of j is printed to the console in each iteration.
After the loop finishes, the code tries to print i * j. However, this is tricky! The scope of j is only inside the loop. Once the loop finishes, j no longer exists.
Therefore, you will get a compile-time error because j is not accessible outside the loop.

Why other options are incorrect:
Options A, B, and D show possible outputs if the code were to run without error. Since j is out of scope, these outputs are impossible.

The Correct Answer:
The correct answer is C: Compile time error because the variable j is not accessible outside the for loop.
67
Correct Declaration of Values to variables 'a' and 'b'?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
68
What is the Size of 'Char' datatype?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
69
What will be the output of the following C# code?
static void Main(string[] args)
{
    int x = 1;
    float y = 2. 4f;
    short z = 1;
    Console. WriteLine((float) x + y * z - (x + = (short) y) );
    Console. ReadLine();
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
70
Why does a float variable stop incrementing at number '16777216' in the following C# code?
float a = 0 ;
while (true)
{
    a++;
    if (a > 16777216)
    break;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board