MCQOPTIONS
Saved Bookmarks
This section includes 24 Mcqs, each offering curated multiple-choice questions to sharpen your C Sharp Programming knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
For the code snippet given below, which of the following statements are valid? public class MyContainer where T: class, IComparable { //Insert code here }Class MyContainer requires that it's type argument must implement IComparable interface. Compiler will report an error for this block of code. There are multiple constraints on type argument to MyContainer class. Class MyContainer requires that its type argument must be a reference type and it must implement IComparable interface. |
| A. | 1 and 2 Only |
| B. | 3 and 4 Only |
| C. | 2 and 3 Only |
| D. | All of the above |
| E. | None of the above |
| Answer» C. 2 and 3 Only | |
| 2. |
For the code snippet given below, which of the following statements are valid? public class MyContainer where T: IComparabte { // Insert code here }Class MyContainer requires that it's type argument must implement IComparabte interface. Type argument of class MyContainer must be IComparabte. Compiler will report an error for this block of code. This requirement on type argument is called as constraint. |
| 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 |
| Answer» D. All of the above | |
| 3. |
Which of the following can be used as a generic in a complex digital design with many inputs and two outputs? |
| A. | Number of outputs |
| B. | Number of inputs |
| C. | Intermediate signals |
| D. | No parameter |
| Answer» C. Intermediate signals | |
| 4. |
Generics in VHDL can be treated as _______ |
| A. | Global variable |
| B. | Local variable |
| C. | Variable |
| D. | Signal |
| Answer» B. Local variable | |
| 5. |
Which function is used to map a generic on design? |
| A. | Port map() |
| B. | Generic() |
| C. | Generic map() |
| D. | Port |
| Answer» D. Port | |
| 6. |
GENERIC (n : INTEGER := 8); In this statement, the mode of generic ‘n’ is _______ |
| A. | Integer |
| B. | Real |
| C. | Generic |
| D. | No Mode |
| Answer» E. | |
| 7. |
In most synthesis tools, only generics of type ________ are supported. |
| A. | INTEGER |
| B. | REAL |
| C. | BIT_VECTOR |
| D. | STD_LOGIC |
| Answer» B. REAL | |
| 8. |
A generic can’t be declared in a component declaration. |
| A. | True |
| B. | False |
| Answer» C. | |
| 9. |
Which of the following is true about Generics? |
| A. | Generics can be assigned information as part of simulation run |
| B. | Generics cannot be assigned information as part of simulation run |
| C. | Generic passes data to an entity which is not instance specific |
| D. | Results of simulation can modify the value of generics |
| Answer» C. Generic passes data to an entity which is not instance specific | |
| 10. |
More than one generic parameter can be defined in a single entity. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 11. |
What is the main use of the generic parameter? |
| A. | Defining constant type |
| B. | Assigning some initial value to constant |
| C. | Reusability |
| D. | Using constant type within the entity |
| Answer» D. Using constant type within the entity | |
| 12. |
Which of the following is correct declaration for a generic? |
| A. | GENERIC (name : type := initial_value); |
| B. | GENERIC (type : name := initial_value); |
| C. | GENERIC (name : type <= initial_value); |
| D. | GENERIC ( ype : name <= initial_valu |
| E. | ;b) GENERIC (type : name := initial_value);c) GENERIC (name : type <= initial_value);d) GENERIC ( ype : name <= initial_value); |
| Answer» B. GENERIC (type : name := initial_value); | |
| 13. |
In which part of the VHDL code, generics are declared? |
| A. | Package declaration |
| B. | Entity |
| C. | Architecture |
| D. | Configurations |
| Answer» C. Architecture | |
| 14. |
Which one of the following classes are present System.Collections.Generic namespace? 1.Stack 2.Tree 3.SortedDictionary 4.SortedArray |
| A. | 2 and 4 only |
| B. | 1 and 2 only |
| C. | All of the above |
| D. | 1 and 3 only |
| Answer» E. | |
| 15. |
Which of the following statements is valid about generic procedures in C#.NET? |
| A. | All procedures in a Generic class are generic. |
| B. | Only those procedures labeled as Generic are generic. |
| C. | Generic procedures can take at the most one generic parameter. |
| D. | Generic procedures must take at least one type parameter. |
| E. | None of the above. |
| Answer» E. None of the above. | |
| 16. |
For the code snippet given below, which of the following statements are valid? public class MyContainer where T: IComparabte { // Insert code here } Class MyContainer requires that it's type argument must implement IComparabte interface. Type argument of class MyContainer must be IComparabte. Compiler will report an error for this block of code. This requirement on type argument is called as constraint. |
| A. | 1 and 2 Only |
| B. | 1, 2 and 3 Only |
| C. | 1 and 4 Only |
| D. | All of the above |
| Answer» D. All of the above | |
| 17. |
Which of the following statements is valid about advantages of generics? |
| A. | Generics shift the burden of type safety to the programmer rather than compiler. |
| B. | Generics require use of explicit type casting. |
| C. | Generics provide type safety without the overhead of multiple implementations. |
| D. | Generics eliminate the possibility of run-time errors. |
| Answer» D. Generics eliminate the possibility of run-time errors. | |
| 18. |
For the code snippet given below, which of the following statements are valid? public class MyContainer where T: class, IComparable { //Insert code here } Class MyContainer requires that it's type argument must implement IComparable interface. Compiler will report an error for this block of code. There are multiple constraints on type argument to MyContainer class. Class MyContainer requires that its type argument must be a reference type and it must implement IComparable interface. |
| A. | 1 and 2 Only |
| B. | 3 and 4 Only |
| C. | 2 and 3 Only |
| D. | All of the above |
| Answer» C. 2 and 3 Only | |
| 19. |
For the code snippet shown below, which of the following statements are valid? public class Generic { public T Field; public void TestSub() { T i = Field + 1; } } class MyProgram { static void Main(string[] args) { Generic gen = new Generic(); gen.TestSub(); } } |
| A. | Addition will produce result 1. |
| B. | Result of addition is system-dependent. |
| C. | Program will generate run-time exception. |
| D. | Compiler will report an error: Operator '+' is not defined for types T and int. |
| Answer» E. | |
| 20. |
For the code snippet shown below, which of the following statements are valid? public class TestIndiaBix { public void TestSub (M arg) { Console.Write(arg); } } class MyProgram { static void Main(string[] args) { TestIndiaBix bix = new TestIndiaBix(); bix.TestSub("IndiaBIX "); bix.TestSub(4.2f); } } |
| A. | Program will compile and on execution will print: IndiaBIX 4.2 |
| B. | A non generic class Hello cannot have generic subroutine. |
| C. | Compiler will generate an error. |
| D. | Program will generate a run-time exception. |
| Answer» B. A non generic class Hello cannot have generic subroutine. | |
| 21. |
For the code snippet given below, which of the following statements is valid? public class Generic { public T Field; } class Program { static void Main(string[ ] args) { Generic g = new Generic(); g.Field = "Hello"; Console.WriteLine(g.Field); } } |
| A. | It will print string "Hello" on the console. |
| B. | Name Generic cannot be used as a class name because it's a keyword. |
| C. | Compiler will give an error. |
| D. | Member Field of class Generic is not accessible directly. |
| Answer» B. Name Generic cannot be used as a class name because it's a keyword. | |
| 22. |
Which of the following statements is valid about generic procedures in C#.NET? |
| A. | All procedures in a Generic class are generic. |
| B. | Only those procedures labeled as Generic are generic. |
| C. | Generic procedures can take at the most one generic parameter. |
| D. | Generic procedures must take at least one type parameter. |
| Answer» E. | |
| 23. |
Which of the following statements are valid about generics in .NET Framework? Generics is a language feature. We can create a generic class, however, we cannot create a generic interface in C#.NET. Generics delegates are not allowed in C#.NET. Generics are useful in collection classes in .NET framework. None of the above |
| A. | 1 and 2 Only |
| B. | 1, 2 and 3 Only |
| C. | 1 and 4 Only |
| D. | All of the above |
| Answer» D. All of the above | |
| 24. |
Which one of the following classes are present System.Collections.Generic namespace? Stack Tree SortedDictionary SortedArray |
| A. | 1 and 2 only |
| B. | 2 and 4 only |
| C. | 1 and 3 only |
| D. | All of the above |
| Answer» D. All of the above | |