ExamVeda
Login
Home
61
What will be the output of the following C# code?
{
    try 
    {
        int []a = {1, 2, 3, 4, 5};
        for (int i = 0; i < 7; ++i) 
        Console.WriteLine(a[i]);
    }
    catch(IndexOutOfRangeException e) 
    {
        Console.WriteLine("0");        	
    }
    Console.ReadLine();
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
62
Select the modifiers which can be used with the properties?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
63
Which of the following is the wrong statement about exception handling in C#.NET?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
64
Which of these keywords are used for the block to handle the exceptions generated by try block?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
65
What will be the output of the following C# code?
class student
{
    int []scores = new int[5] {23, 42, 54, 11, 65};
    public int this[int index]
    {
        get
        {
            if (index < 5)
            return scores[index];
            else
            {
                Console.WriteLine("invalid index");
                return 0;
            }
        }
        set
        {
            if (index < 5)
            scores[index] = value;
            else
            Console.WriteLine("invalid index");
        }
    }
}
class Program
{
    public static void Main(string[] args)
    {
        student s = new student();
        Console.WriteLine(s[4] + 8);
        Console.ReadLine();
    }
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
66
Select the statements which describe the correct usage of exception handling over conventional error handling approaches?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
67
Which of these exceptions will occur if we try to access the index of an array beyond its length?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
68
Consider a class maths and we had a property called as sum.b which is the reference to a maths object and we want the statement Console.WriteLine(b.sum)to fail. Which among the following is the correct solution to ensure this functionality?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
69
Consider a class maths and we had a property called as sum.b is a reference to a maths object and we want the code below to work. Which is the correct solution to ensure this functionality?
b.maths = 10;
Console.WriteLine(b.maths);
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
70
What will be the output of the following C# code?
class program
{
    static void main(string[] args)
    {
        int i = 5;
        int v = 40;
        int[] p = new int[4];
        try
        {
            p[i] = v;
        }
        catch(IndexOutOfRangeException e)
        {
            Console.WriteLine("Index out of bounds");
        }
        Console.WriteLine("Remaining program");
    }
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board