Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. Which among the following is the correct way to access all the elements of the Stack collection created using the C#.NET code snippet given below?Stack st = new Stack();st.Push(10);st.Push(20);st.Push(-5);st.Push(30);st.Push(6);
  1.    IEnumerable e;e = st.GetEnumerator();while (e.MoveNext())Console.WriteLine(e.Current);
  2.    IEnumerator e; e = st.GetEnumerator(); while(e.MoveNext()) Console.WriteLine(e.Current);
  3.    IEnumerable e; e = st.GetEnumerable(); while(e.MoveNext()) Console.WriteLine(e.Current);
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> IEnumerator e; e = st.GetEnumerator(); while(e.MoveNext()) Console.WriteLine(e.Current);




Question 2. The property signifies "Obtains a Module object that represents the module (an executable file) in which the reflected type resides. Choose the property which specifies the following statement:
  1.    Type DeclaringType
  2.    int MetadataToken
  3.    Module Module
  4.    Type ReflectedType
 Discuss Question
Answer: Option C. -> Module Module




Question 3. What will the given code snippet specify?class MyClass{    char chrs = 'A' ;    public IEnumerator GetEnumerator()    {        for (int i = 20; i >=0; --i)        if (i == 10) yield break;        yield return (char)((chrs + i));    }}class Program{    static void Main(string[] args)    {        MyClass mc = new MyClass();        foreach (char ch in mc)        Console.Write(ch + " ");        Console.WriteLine();        Console.ReadLine();    }}
  1.    Code run successfully prints nothing
  2.    A B C D E F G H I J K L M N O P Q R S T U V
  3.    U T S R Q P O N M L
  4.    Compile time error
 Discuss Question
Answer: Option C. -> U T S R Q P O N M L


The code to specify stoppage of the iterator using 'yield break' statement When this statement executes, the iterator signals that the end of the collection has been reached, which effectively stops the iterator.
Output: U T S R Q P O N M L


Question 4. What will be the output of the given code snippet?class Program{    static void Main(string[] args)    {        int[] nums = { 1 };        var posNums = from n in nums                      select Math.Pow(4 ,3);        Console.Write("The values in nums: ");        foreach (int i in posNums)         Console.Write(i + " ");        Console.WriteLine();        Console.ReadLine();    }}
  1.    Run time error
  2.    64
  3.    Compile time error
  4.    81
 Discuss Question
Answer: Option B. -> 64




Question 5. Number of threads that exists for each of the processes that occurs in the program:
  1.    atmost 1
  2.    atleast 1
  3.    only 1
  4.    Both a & c
 Discuss Question
Answer: Option D. -> Both a & c


All processes have at least one thread for execution, which is usually called the main thread because it is the primary thread that is
executed when our program begins.From the main thread, we can create other threads.


Question 6. What is mutex?
  1.    a mutually exclusive synchronization object
  2.    can be acquired by more than one thread at a time
  3.    helps in sharing of resource which can be used by one thread
  4.    All of the mentioned
 Discuss Question
Answer: Option A. -> a mutually exclusive synchronization object


A mutex is a mutually exclusive synchronization object. This means it can be acquired by one and only one thread at a time. The mutex is designed for those situations in which a shared resource can be used by only one thread at a time


Question 7. Which of the following functions return absolute value of a variable?
  1.    Abs()
  2.    Absolute()
  3.    absolutevariable()
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Abs()


Abs() returns the absolute value of a variable


Question 8. The correct code to access all the elements of the queue collection created using the C#.NET code snippets given below is?Queue q = new Queue();q.Enqueue("Harsh");q.Enqueue('a');q.Enqueue(false);q.Enqueue(70);q.Enqueue(8.5);
  1.    IEnumerator e;e = q.GetEnumerator(); while(e.MoveNext()) Console.WriteLine(e.Current);
  2.    IEnumerable e; e = q.GetEnumerator(); while(e.MoveNext())
  3.    IEnumerable e e = q.GetEnumerable(); while(e.MoveNext()) Console.WriteLine(e.Current);
  4.    All of the mentioned
 Discuss Question
Answer: Option A. -> IEnumerator e;e = q.GetEnumerator(); while(e.MoveNext()) Console.WriteLine(e.Current);




Question 9. Choose the method defined by MemberInfo:
  1.    GetCustomAttributes()
  2.    IsDefined()
  3.    GetCustomeAttributesData()
  4.    All of the mentioned
 Discuss Question
Answer: Option D. -> All of the mentioned


MemberInfo includes two abstract methods: GetCustomAttributes( ) and IsDefined( ). These both relate to attributes. The first obtains a list of the custom attributes associated with the invoking object. The second determines if an attribute is defined for the invoking object. The .NET Framework Version 4.0 adds a method called GetCustomAttributesData(), which returns information about custom attributes


Question 10. What will be the output of the code snippet?class MyClass {     int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};     public IEnumerator GetEnumerator()     {         for (int i = 0; i < 20; i++)         {             if (a[i] % 2 == 0)             yield return (int)(a[i]);         }     } } class Program {     static void Main(string[] args)     {         MyClass mc = new MyClass();         foreach (int i in mc)         Console.Write(i + " ");         Console.WriteLine();         Console.ReadLine();     } }
  1.    prints nothing code run successfully
  2.    run time error
  3.    code runs successfully prints even number between 1 to 20
  4.    Compile time error
 Discuss Question
Answer: Option C. -> code runs successfully prints even number between 1 to 20


Output: 2, 4, 6, 8, 10, 12, 14, 16, 18, 20


Latest Videos

Latest Test Papers