CSharp Programming

CSharp Programming

Attributes has 15 Questions
The [Serializable()] attribute gets inspected at

Compile-time
Run-time
Design-time
Linking-time
Which of the following are correct ways to specify the targets for a custom attribute?

By applying AttributeUsage to the custom attribute's class definition.
By applying UsageAttribute to the custom attribute's class definition.
Once an attribute is declared it applies to all the targets.
By applying AttributeUsageAttribute to the custom attribute's class definition.
Which of the following are correct ways to pass a parameter to an attribute?
  1. By value
  2. By reference
  3. By address
  4. By position
  5. By name

1, 2
1, 2, 3
4, 5
All of the above
Which of the following statements are correct about inspecting an attribute in C#.NET?
  1. An attribute can be inspected at link-time.
  2. An attribute can be inspected at compile-time.
  3. An attribute can be inspected at run-time.
  4. An attribute can be inspected at design-time.

1, 2
3, 4
1, 3, 4
All of the above
Which of the following is correct ways of applying an attribute?

[WebService (Name = "ASTIWZ", Description = "QUIZ WebService")] class AuthenticationService: WebService

{ /* .... */}

[WebService (Name = "ASTIWZ", Description = "QUIZ WebService")] class AuthenticationService: inherits WebService

{ /* .... */}

[WebService (Name = "ASTIWZ", Description = "QUIZ WebService")] class AuthenticationService: extends WebService

{ /* .... */}

[WebService ( Name := "ASTIWZ", Description := "QUIZ WebService")] class AuthenticationService: inherits WebService

{ /* .... */}

Which of the following statements are correct about Attributes used in C#.NET?

If there is a custom attribute BugFixAttribute then the compiler will look ONLY for the BugFix attribute in the code that uses this attribute.
To create a custom attribute we need to create a custom attribute structure and derive it from System.Attribute.
To create a custom attribute we need to create a class and implement IAttribute interface in it.
The CLR can change the behaviour of the code depending upon the attributes applied to it.
Which of the following forms of applying an attribute is correct?

< Serializable() > class sample { /* ... */ }
(Serializable()) class sample { /* ... */ }
[ Serializable() ] class sample { /* ... */ }
Serializablef) class sample { /* ... */ }
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.

1 and 2 only
2 and 4 only
1, 4 and 5 only
All of the above
Which of the following correctly describes the contents of the filename AssemblyInfo.cs?

It contains method-level attributes.
It contains class-level attributes.
It contains assembly-level attributes.
It contains structure-level attributes.
It possible to create a custom attribute that can be applied only to specific programming element(s) like ____ .

Classes
Methods
Classes and Methods
Classes, Methods and Member-Variables
Which of the following CANNOT be a target for a custom attribute?

Enum
Event
Delegate
Namespace
Once applied which of the following CANNOT inspect the applied attribute?

CLR
Linker
ASP.NET Runtime
Visual Studio.NET
Which of the following is the correct way to apply an attribute to an Assembly?

[ AssemblyDescription("DCube Component Library") ]
[ assembly : AssemblyDescription("DCube Component Library") ]
[ Assemblylnfo : AssemblyDescription("DCube Component Library") ]
< Assembly: AssemblyDescription("DCube Component Library") >
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.

1 only
1, 5
2, 3
4, 5
Attributes can be applied to
  1. Method
  2. Class
  3. Assembly
  4. Namespace
  5. Enum

1 and 2 only
1, 2 and 3
4 and 5 only
All of the above