logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Attributes See What Others Are Saying!
  • Question
  • Which of the following statements are correct about Attributes in C#.NET?

    1. On compiling a C#.NET program the attibutes applied are recorded in the metadata of the assembly.
    2. On compilation all the attribute's tags are deleted from the program.
    3. It is not possible to create custom attributes..
    4. The attributes applied can be read from an assembly using Reflection class.
    5. An attribute can have parameters.


  • Options
  • A. 1 and 2 only
  • B. 2 and 4 only
  • C. 1, 4 and 5 only
  • D. All of the above
  • E. None of the above

  • Correct Answer
  • 1, 4 and 5 only 


  • More questions

    • 1. A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement stu.RollNo = 28 to fail. Which of the following options will ensure this functionality?

    • Options
    • A. Declare rollNo property with both get and set accessors.
    • B. Declare rollNo property with only set accessor.
    • C. Declare rollNo property with get, set and normal accessors.
    • D. Declare rollNo property with only get accessor.
    • E. None of the above
    • Discuss
    • 2. Which of the following is the correct way to apply an attribute to an Assembly?

    • Options
    • A. [ AssemblyDescription("DCube Component Library") ]
    • B. [ assembly : AssemblyDescription("DCube Component Library") ]
    • C. [ Assemblylnfo : AssemblyDescription("DCube Component Library") ]
    • D. < Assembly: AssemblyDescription("DCube Component Library") >
    • E. (Assembly: AssemblyDescription("DCube Component Library"))
    • Discuss
    • 3. Which of the following are correct ways to specify the targets for a custom attribute?

    • Options
    • A. By applying AttributeUsage to the custom attribute's class definition.
    • B. By applying UsageAttribute to the custom attribute's class definition.
    • C. Once an attribute is declared it applies to all the targets.
    • D. By applying AttributeUsageAttribute to the custom attribute's class definition.
    • E. None of the above.
    • Discuss
    • 4. Which of the following is the correct way to define a variable of the type struct Emp declared below?

      struct Emp
      {
          private String name; 
          private int age; 
          private Single sal;
      }
      1. Emp e(); e = new Emp();
      2. Emp e = new Emp;
      3. Emp e; e = new Emp;
      4. Emp e = new Emp();
      5. Emp e;

    • Options
    • A. 1, 3
    • B. 2, 5
    • C. 4, 5
    • D. 1, 2, 4
    • Discuss
    • 5. If Sample class has a Length property with set accessor then which of the following statements will work correctly?

    • Options
    • A.
      Sample m = new Sample(); 
      int l;
      l = m.Length;
    • B.
      Sample m = new Sample(); 
      m.Length = m.Length + 20;
    • C.
      Sample.Length = 20;
    • D.
      Console.WriteLine (Sample.Length);
    • E.
      Sample m = new Sample(); 
      m.Length = 10;
    • Discuss
    • 6. Which of the following is the correct way to define and initialise an array of 4 integers?

      1. int[] a = {25, 30, 40, 5};
      2. int[] a;
        a = new int[3];
        a[0] = 25;
        a[1] = 30;
        a[2] = 40;
        a[3] = 5;
      3. int[] a;
        a = new int{25, 30, 40, 5};
      4. int[] a;
        a = new int[4]{25, 30, 40, 5};
      5. int[] a;
        a = new int[4];
        a[0] = 25;
        a[1] = 30;
        a[2] = 40;
        a[3] = 5;

    • Options
    • A. 1, 2
    • B. 3, 4
    • C. 1, 4, 5
    • D. 2, 4, 5
    • E. 2, 5
    • Discuss
    • 7. Which of the following is NOT an interface declared in System.Collections namespace?

    • Options
    • A. IComparer
    • B. IEnumerable
    • C. IEnumerator
    • D. IDictionaryComparer
    • E. IDictionaryEnumerator
    • Discuss
    • 8. Which of the following will be the correct output for the C#.NET code snippet given below?

      String s1 = "ALL MEN ARE CREATED EQUAL";
      String s2;
      s2 = s1.Substring(12, 3); 
      Console.WriteLine(s2);

    • Options
    • A. ARE
    • B. CRE
    • C. CR
    • D. REA
    • E. CREATED
    • Discuss
    • 9. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class SampleProgram
          {
              static void Main(string[ ] args)
              {
                  int i = 10;
                  double d = 34.340;
                  fun(i);
                  fun(d);
              }
              static void fun(double d)
              {
                  Console.WriteLine(d + " ");
              }
          }
      }

    • Options
    • A. 10.000000 34.340000
    • B. 10 34
    • C. 10 34.340
    • D. 10 34.34
    • Discuss
    • 10. Which of the following statements is correct?

    • Options
    • A. It is not possible to extend the if statement to handle multiple conditions using the else-if arrangement.
    • B. The switch statement can include any number of case instances with two case statements having the same value.
    • C. A jump statement such as a break is required after each case block excluding the last block if it is a default statement.
    • D. The if statement selects a statement for execution based on the value of a Boolean expression.
    • E. C# always supports an implicit fall through from one case label to another.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment