logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Collection Classes See What Others Are Saying!
  • Question
  • Which of the following statements are correct about the C#.NET code snippet given below?

    Stack st = new Stack();
    st.Push("hello");
    st.Push(8.2);
    st.Push(5);
    st.Push('b');
    st.Push(true);


  • Options
  • A. Dissimilar elements like "hello", 8.2, 5 cannot be stored in the same Stack collection.
  • B. Boolean values can never be stored in Stack collection.
  • C. In the fourth call to Push(), we should write "b" in place of 'b'.
  • D. To store dissimilar elements in a Stack collection, a method PushAnyType() should be used in place of Push().
  • E. This is a perfectly workable code.

  • Correct Answer
  • This is a perfectly workable code. 


  • More questions

    • 1. C#.NET structures are always value types.

    • Options
    • A. True
    • B. False
    • Discuss
    • 2. What does the following C#.NET code snippet will print?

      int i = 0, j = 0; 
      
      label:
          i++;
          j+=i;
      if (i < 10)
      {
          Console.Write(i +" ");
          goto label; 
      }

    • Options
    • A. Prints 1 to 9
    • B. Prints 0 to 8
    • C. Prints 2 to 8
    • D. Prints 2 to 9
    • E. Compile error at label:.
    • Discuss
    • 3. The [Serializable()] attribute gets inspected at

    • Options
    • A. Compile-time
    • B. Run-time
    • C. Design-time
    • D. Linking-time
    • E. None of the above
    • Discuss
    • 4. Code that targets the Common Language Runtime is known as

    • Options
    • A. Unmanaged
    • B. Distributed
    • C. Legacy
    • D. Managed Code
    • E. Native Code
    • Discuss
    • 5. Which of the following are the correct ways to declare a delegate for calling the function func() defined in the sample class given below?

      class Sample
      {
          public int func(int i, Single j)
          {
              /* Add code here. */
          }
      }

    • Options
    • A. delegate d(int i, Single j);
    • B. delegate void d(int, Single);
    • C. delegate int d(int i, Single j);
    • D. delegate void (int i, Single j);
    • E. delegate int sample.func(int i, Single j);
    • Discuss
    • 6. Which of the following statements is correct about properties used in C#.NET?

    • Options
    • A. Every property must have a set accessor and a get accessor.
    • B. Properties cannot be overloaded.
    • C. Properties of a class are actually methods that work like data members.
    • D. A property has to be either read only or a write only.
    • Discuss
    • 7. Which of the following assemblies can be stored in Global Assembly Cache?

    • Options
    • A. Private Assemblies
    • B. Friend Assemblies
    • C. Shared Assemblies
    • D. Public Assemblies
    • E. Protected Assemblies
    • Discuss
    • 8. Which of the following statements are correct?

      1. A struct can contain properties.
      2. A struct can contain constructors.
      3. A struct can contain protected data members.
      4. A struct cannot contain methods.
      5. A struct cannot contain constants.

    • Options
    • A. 1, 2
    • B. 3, 4
    • C. 1, 2, 4
    • D. 3, 5
    • Discuss
    • 9. Which of the following is the correct size of a Decimal datatype?

    • Options
    • A. 8 Bytes
    • B. 4 Bytes
    • C. 10 Bytes
    • D. 16 Bytes
    • E. None of the above.
    • Discuss
    • 10. 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.

    • Options
    • A. 1, 2
    • B. 3, 4
    • C. 1, 3, 4
    • D. All of the above
    • E. None of the above
    • Discuss


    Comments

    There are no comments.

Enter a new Comment