logo

CuriousTab

CuriousTab

Discussion


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

  • Correct Answer
  • 1, 2 and 3 


  • More questions

    • 1. Which of the following are the correct ways to define an array of 2 rows and 3 columns?

      1. int[ , ] a;
        a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
      2. int[ , ] a;
        a = new int[2, 3]{};
      3. int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
      4. int[ , ] a;
        a = new int[1, 2];
      5. int[ , ] a;
        a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};

    • Options
    • A. 1, 2 , 3
    • B. 1, 3
    • C. 2, 3
    • D. 2, 4, 5
    • E. 4, 5
    • Discuss
    • 2. Which of the following is the correct way to find out the index of the second 's' in the string "She sells sea shells on the sea-shore"?

    • Options
    • A.
      String str = "She sells sea shells on the sea-shore"; 
      int i;
      i = str.SecondIndexOf("s");
    • B.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.FirstIndexOf("s"); 
      j = str.IndexOf("s", i + 1);
    • C.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.IndexOf("s"); 
      j = str.IndexOf("s", i + 1);
    • D.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.LastIndexOf("s"); 
      j = str.IndexOf("s", i - 1);
    • E.
      String str = "She sells sea shells on the sea-shore"; 
      int i, j;
      i = str.IndexOf("S"); 
      j = str.IndexOf("s", i);
    • Discuss
    • 3. Which of the following statements is correct about the C#.NET program given below?

      namespace CuriousTabConsoleApplication
      {
          class Baseclass
          { 
              int i;
              public Baseclass(int ii)
              {
                  i = ii;
                  Console.Write("Base "); 
              } 
          } 
          class Derived : Baseclass
          {
              public Derived(int ii) : base(ii)
              {
                  Console.Write("Derived ");
              } 
          } 
          class MyProgram
          { 
              static void Main(string[ ] args)
              { 
                  Derived d = new Derived(10);
              } 
          } 
      }

    • Options
    • A. The program will work correctly only if we implement zero-argument constructors in Baseclass as well as Derived class.
    • B. The program will output: Derived Base
    • C. The program will report an error in the statement base(ii).
    • D. The program will work correctly if we replace base(ii) with base.Baseclass(ii).
    • E. The program will output: Base Derived
    • Discuss
    • 4. Multiple inheritance is different from multiple levels of inheritance.

    • Options
    • A. True
    • B. False
    • Discuss
    • 5. Which of the following is NOT a .NET Exception class?

    • Options
    • A. Exception
    • B. StackMemoryException
    • C. DivideByZeroException
    • D. OutOfMemoryException
    • E. InvalidOperationException
    • Discuss
    • 6. Which of the followings is the correct way to overload + operator?

    • Options
    • A.
      public sample operator + ( sample a, sample b )
    • B.
      public abstract operator + ( sample a, sample b)
    • C.
      public abstract sample operator + (sample a, sample b )
    • D.
      public static sample operator + ( sample a, sample b )
    • E. All of the above
    • Discuss
    • 7. A property can be declared inside a namespace or a procedure.

    • Options
    • A. True
    • B. False
    • Discuss
    • 8. 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
    • 9. 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
    • 10. 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


    Comments

    There are no comments.

Enter a new Comment