Attributes



1. Which of the following are correct ways to specify the targets for a custom attribute?  

  • 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.


2. Which of the following statements are correct about inspecting an attribute in C#.NET?  

  • A) An attribute can be inspected at link-time.
  • B) An attribute can be inspected at compile-time
  • C) An attribute can be inspected at design-time.
  • D) An attribute can be inspected at run-time.
  • E) None of the above


3. Which of the following correctly describes the contents of the filename AssemblyInfo.cs?  

  • A) It contains method-level attributes.
  • B) It contains class-level attributes.
  • C) It contains namespace-level attributes.
  • D) It contains structure-level attributes.
  • E) It contains assembly-level attributes.


4. It possible to create a custom attribute that can be applied only to specific programming element(s) like  

  • A) Classes
  • B) Methods
  • C) Classes and Methods
  • D) Classes, Methods and Member-Variables
  • E) Member-Variables



5. Which of the following CANNOT be a target for a custom attribute?  

  • A) Enum
  • B) Event
  • C) Delegate
  • D) Interface
  • E) Namespace


6. Once applied which of the following CANNOT inspect the applied attribute?  

  • A) CLR
  • B) ASP.NET Runtime
  • C) Linker
  • D) Language compilers
  • E) Visual Studio.NET


7. Attributes can be applied to  

  • A) Method
  • B) Class
  • C) Assembly
  • D) Namespace
  • E) Enum


8. The [Serializable()] attribute gets inspected at  

  • A) Compile-time
  • B) Run-time
  • C) Design-time
  • D) Linking-time


9. Which of the following are correct ways to specify the targets for a custom attribute?  

  • A) By applying AttributeUsage to the custom attribute's class definition.
  • B) By applying UsageAttribute to the custom attribute's class definition.
  • C) By applying AttributeUsageAttribute to the custom attribute's class definition.
  • D) Once an attribute is declared it applies to all the targets.


10. Which of the following are correct ways to pass a parameter to an attribute?  

  • A) By value
  • B) By reference
  • C) By address
  • D) By name
  • E) By position


11. Which of the following statements are correct about inspecting an attribute in C#.NET?  

  • A) An attribute can be inspected at link-time.
  • B) An attribute can be inspected at compile-time.
  • C) An attribute can be inspected at run-time.
  • D) An attribute can be inspected at design-time.


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

  • 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.


13. Which of the following correctly describes the contents of the filename AssemblyInfo.cs?  

  • A) It contains method-level attributes.
  • B) It contains class-level attributes.
  • C) It contains assembly-level attributes.
  • D) It contains structure-level attributes
  • E) It contains namespace-level attributes.


14. It possible to create a custom attribute that can be applied only to specific programming element(s) like ____ .  

  • A) Classes
  • B) Methods
  • C) Classes and Methods
  • D) Classes, Methods and Member-Variables


15. Which of the following CANNOT be a target for a custom attribute?  

  • A) Enum
  • B) Event
  • C) Delegate
  • D) Interface
  • E) Namespace


16. Once applied which of the following CANNOT inspect the applied attribute?  

  • A) CLR
  • B) Linker
  • C) Asp.Net Runtime
  • D) Visual Studio .Net
  • E) Linkers and Compilers


17. Attributes can be applied to  

  • A) Method
  • B) Class
  • C) Assembly
  • D) Namespace
  • E) Enum


18. What are C# attributes and its significance?  

C# provides developers a way to define declarative tags on certain entities eg. Class, method etc. are called attributes. The attribute’s information can be retrieved at runtime using Reflection.


Java Interview Question

.Net Interview Question

PHP Interview Question

AngularJS Interview Questions