logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Operators See What Others Are Saying!
  • Question
  • Which of the following statements are correct?

    1. The conditional operator (?:) returns one of two values depending on the value of a Boolean expression.
    2. The as operator in C#.NET is used to perform conversions between compatible reference types.
    3. The &* operator is also used to declare pointer types and to dereference pointers.
    4. The -> operator combines pointer dereferencing and member access.
    5. In addition to being used to specify the order of operations in an expression, brackets [ ] are used to specify casts or type conversions.


  • Options
  • A. 1, 2, 4
  • B. 2, 3, 5
  • C. 3, 4, 5
  • D. 1, 3, 5
  • E. None of these

  • Correct Answer
  • 1, 2, 4 


  • More questions

    • 1. A property can be declared inside a namespace or a procedure.

    • Options
    • A. True
    • B. False
    • Discuss
    • 2. How many times can a constructor be called during lifetime of the object?

    • Options
    • A. As many times as we call it.
    • B. Only once.
    • C. Depends upon a Project Setting made in Visual Studio.NET.
    • D. Any number of times before the object gets garbage collected.
    • E. Any number of times before the object is deleted.
    • Discuss
    • 3. Which of the following is the correct way of applying the custom attribute called Tested which receives two-arguments - name of the tester and the testgrade?

      1. Custom attribute cannot be applied to an assembly.
      2. [assembly: Tested("Sachin", testgrade.Good)]
      3. [Tested("Virat", testgrade.Excellent)]
        class customer { /* .... */ }
      4. Custom attribute cannot be applied to a method.
      5. Custom attribute cannot be applied to a class.

    • Options
    • A. 1 only
    • B. 1, 5
    • C. 2, 3
    • D. 4, 5
    • E. None of the above
    • Discuss
    • 4. Which of the following statements are correct about Attributes used in C#.NET?

    • Options
    • A. If there is a custom attribute BugFixAttribute then the compiler will look ONLY for the BugFix attribute in the code that uses this attribute.
    • B. To create a custom attribute we need to create a custom attribute structure and derive it from System.Attribute.
    • C. To create a custom attribute we need to create a class and implement IAttribute interface in it.
    • D. If a BugFixAttribute is to receive three parameters then the BugFixAttribute class should implement a zero-argument constructor.
    • E. The CLR can change the behaviour of the code depending upon the attributes applied to it.
    • Discuss
    • 5. Which of the following is the correct output of the C#.NET code snippet given below?

          int[][] a = new int[2][];
          a[0] = new int[4]{6, 1, 4, 3};
          a[1] = new int[3]{9, 2, 7}; 
          Console.WriteLine(a[1].GetUpperBound(0));

    • Options
    • A. 3
    • B. 4
    • C. 7
    • D. 9
    • E. 2
    • Discuss
    • 6. Attributes can be applied to

      1. Method
      2. Class
      3. Assembly
      4. Namespace
      5. Enum

    • Options
    • A. 1 and 2 only
    • B. 1, 2 and 3
    • C. 4 and 5 only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 7. Which of the following statements is correct about the C#.NET program given below if a value "6" is input to it?

      using System;
      namespace CuriousTabConsoleApplication
      {
          class MyProgram
          {
              static void Main (string[] args)
              {
                  int index; 
                  int val = 66; 
                  int[] a = new int[5]; 
                  try
                  {
                      Consote.Write("Enter a number: "); 
                      index = Convert.ToInt32(Console.ReadLine()); 
                      a[index] = val;
                  }
                  catch(Exception e)
                  {
                      Console.Write("Exception occurred ");
                  }
                  Console.Write("Remaining program ");
              }
          }
      }

    • Options
    • A. It will output: Exception occurred
    • B. It will output: Remaining program
    • C. It will output: Exception occurred Remaining program
    • D. It will output: Remaining program Exception occurred
    • E. The value 66 will get assigned to a[6].
    • Discuss
    • 8. If a base class and a derived class each include a member function with the same name, the member function of the derived class will be called by an object of the derived class

    • Options
    • A. True
    • B. False
    • Discuss
    • 9. Which of the following statements are valid about generics in .NET Framework?

      1. Generics is a language feature.
      2. We can create a generic class, however, we cannot create a generic interface in C#.NET.
      3. Generics delegates are not allowed in C#.NET.
      4. Generics are useful in collection classes in .NET framework.
      5. None of the above

    • Options
    • A. 1 and 2 Only
    • B. 1, 2 and 3 Only
    • C. 1 and 4 Only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 10. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class SampleProgram
          {
              static void Main(string[ ] args)
              {
                  int i = 5;
                  int j;
                  fun1(ref i);
                  fun2(out j);
                  Console.WriteLine(i + ", " + j);
              }
              static void funl(ref int x)
              {
                  x = x * x;
              }
              static void fun2(out int x)
              {
                  x = 6; 
                  x = x * x; 
              }
          }
      }

    • Options
    • A. 5, 6
    • B. 5, 36
    • C. 25, 36
    • D. 25, 0
    • E. 5, 0
    • Discuss


    Comments

    There are no comments.

Enter a new Comment