logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Exception Handling See What Others Are Saying!
  • Question
  • Which of the following statements is correct about the C#.NET program given below?

    using System;
    namespace CuriousTabConsoleApplication
    {
        class MyProgram
        {
            static void Main(string[] args)
            {
                int index = 6;
                int val = 44;
                int[] a = new int[5];
                try
                {
                    a[index] = val ;
                }    
                catch(IndexOutOfRangeException e)
                {
                    Console.Write("Index out of bounds ");
                }
                Console.Write("Remaining program");
            }
        }
    }


  • Options
  • A. Value 44 will get assigned to a[6].
  • B. It will output: Index out of bounds
  • C. It will output: Remaining program
  • D. It will not produce any output.
  • E. It will output: Index out of bounds Remaining program

  • Correct Answer
  • It will output: Index out of bounds Remaining program 


  • More questions

    • 1. In C#.NET if we do not catch the exception thrown at runtime then which of the following will catch it?

    • Options
    • A. Compiler
    • B. CLR
    • C. Linker
    • D. Loader
    • E. Operating system
    • Discuss
    • 2. Which of the folowing does an indexer allow to index in the same way as an array?

      1. A class
      2. A property
      3. A struct
      4. A function
      5. An interface

    • Options
    • A. 1, 3, 5
    • B. 2, 4
    • C. 3, 5
    • D. 3, 4, 5
    • Discuss
    • 3. Which of the following is NOT an Assignment operator in C#.NET?

    • Options
    • A. \=
    • B. /=
    • C. *=
    • D. +=
    • E. %=
    • Discuss
    • 4. How many values is a function capable of returning?

    • Options
    • A. 1
    • B. 0
    • C. Depends upon how many params arguments does it use.
    • D. Any number of values.
    • E. Depends upon how many ref arguments does it use.
    • Discuss
    • 5. Creating empty structures is allowed in C#.NET.

    • Options
    • A. True
    • B. False
    • Discuss
    • 6. It is illegal to make objects of one class as members of another class.

    • Options
    • A. True
    • B. False
    • Discuss
    • 7. All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not.

    • Options
    • A. True
    • B. False
    • Discuss
    • 8. Which of the following ways to create an object of the Sample class given below will work correctly?

      class Sample
      {
          int i;
          Single j;
          double k;
          public Sample (int ii, Single jj, double kk)
          {
              i = ii;
              j = jj;
              k = kk;
          } 
      }

    • Options
    • A. Sample s1 = new Sample();
    • B. Sample s1 = new Sample(10);
    • C. Sample s2 = new Sample(10, 1.2f);
    • D. Sample s3 = new Sample(10, 1.2f, 2.4);
    • E. Sample s1 = new Sample(, , 2.5);
    • Discuss
    • 9. Which of the following will be the correct output for the C#.NET program given below?

      namespace CuriousTabConsoleApplication
      { 
          class SampleProgram
          {
              static void Main(string[] args)
              { 
                  int num = 1;
                  funcv(num); 
                  Console.Write(num + ", "); 
                  funcr(ref num); 
                  Console.Write(num + ", ");
              }
              static void funcv(int num)
              { 
                  num = num + 10; Console.Write(num + ", ");
              }
              static void funcr (ref int num)
              { 
                  num = num + 10; Console.Write(num + ", ");
              } 
          } 
      }

    • Options
    • A. 1, 1, 1, 1,
    • B. 11, 1, 11, 11,
    • C. 11, 11, 11, 11,
    • D. 11, 11, 21, 11,
    • E. 11, 11, 21, 21,
    • Discuss
    • 10. Which of the following operators cannot be overloaded?

      1. true
      2. false
      3. new
      4. ~
      5. sizeof

    • Options
    • A. 1, 3
    • B. 2, 4
    • C. 3, 5
    • D. All of the above
    • Discuss


    Comments

    There are no comments.

Enter a new Comment