logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Functions and Subroutines See What Others Are Saying!
  • Question
  • 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,

  • Correct Answer
  • 11, 1, 11, 11, 


  • More questions

    • 1. Which of the following statements are correct about the C#.NET code snippet given below?

         int[][]intMyArr = new int[2][]; 
         intMyArr[0] = new int[4]{6, 1, 4, 3}; 
         intMyArr[1] = new int[3]{9, 2, 7};

    • Options
    • A. intMyArr is a reference to a 2-D jagged array.
    • B. The two rows of the jagged array intMyArr are stored in adjacent memory locations.
    • C. intMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D array.
    • D. intMyArr refers to intMyArr[0] and intMyArr[1].
    • E. intMyArr refers to intMyArr[1] and intMyArr[2].
    • Discuss
    • 2. Which of the following is an 8-byte Integer?

    • Options
    • A. Char
    • B. Long
    • C. Short
    • D. Byte
    • E. Integer
    • Discuss
    • 3. Which of the following statements is valid about generic procedures in C#.NET?

    • Options
    • A. All procedures in a Generic class are generic.
    • B. Only those procedures labeled as Generic are generic.
    • C. Generic procedures can take at the most one generic parameter.
    • D. Generic procedures must take at least one type parameter.
    • E. None of the above.
    • Discuss
    • 4. The size of a derived class object is equal to the sum of sizes of data members in base class and the derived class.

    • Options
    • A. True
    • B. False
    • Discuss
    • 5. Suppose n is a variable of the type Byte and we wish to put OFF its fourth bit (from right) without disturbing any other bits. Which of the following statements will do this correctly?

    • Options
    • A. n = n && HF7
    • B. n = n & 16
    • C. n = n & 0xF7
    • D. n = n & HexF7
    • E. n = n & 8
    • Discuss
    • 6. Which of the following statements is correct about namespaces in C#.NET?

    • Options
    • A. Namespaces can be nested only up to level 5.
    • B. A namespace cannot be nested.
    • C. There is no limit on the number of levels while nesting namespaces.
    • D. If namespaces are nested, then it is necessary to use using statement while using the elements of the inner namespace.
    • E. Nesting of namespaces is permitted, provided all the inner namespaces are declared in the same file.
    • Discuss
    • 7. If Sample class has a Length property with get and set accessors then which of the following statements will work correctly?

      1. Sample.Length = 20;
      2. Sample m = new Sample(); 
        m.Length = 10;
      3. Console.WriteLine(Sample.Length);
      4. Sample m = new Sample(); 
        int len;
        len = m.Length;
      5. Sample m = new Sample(); 
        m.Length = m.Length + 20;

    • Options
    • A. 1, 3
    • B. 2, 4, 5
    • C. 4 only
    • D. 3, 5
    • Discuss
    • 8. Which of the following statements are correct about exception handling in C#.NET?

      1. try blocks cannot be nested.
      2. In one function, there can be only one try block.
      3. An exception must be caught in the same function in which it is thrown.
      4. All values set up in the exception object are available in the catch block.
      5. While throwing a user-defined exception multiple values can be set in the exception, object.

    • Options
    • A. 1 only
    • B. 1 and 2 only
    • C. 3 only
    • D. 4 and 5 only
    • E. All of the above
    • Discuss
    • 9. Which of the following statements is correct about the C#.NET code snippet given below?

      interface IMyInterface 
      {
          void fun1(); 
          void fun2();
      }
      class MyClass: IMyInterface
      { 
          private int i; 
          void IMyInterface.fun1()
          { 
              // Some code
          } 
      }

    • Options
    • A. Class MyClass is an abstract class.
    • B. Class MyClass cannot contain instance data.
    • C. Class MyClass fully implements the interface IMyInterface.
    • D. Interface IMyInterface should be inherited from the Object class.
    • E. The compiler will report an error since the interface IMyInterface is only partially implemented.
    • Discuss
    • 10. What will be the output of the C#.NET code snippet given below?

      int i, j = 1, k;
      for (i = 0; i < 5; i++)
      {
          k = j++ + ++j;
          Console.Write(k + " ");
      }

    • Options
    • A. 8 4 16 12 20
    • B. 4 8 12 16 20
    • C. 4 8 16 32 64
    • D. 2 4 6 8 10
    • Discuss


    Comments

    There are no comments.

Enter a new Comment