logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Classes and Objects See What Others Are Saying!
  • Question
  • Which of the following statements is correct about classes and objects in C#.NET?


  • Options
  • A. Class is a value type.
  • B. Since objects are typically big in size, they are created on the stack.
  • C. Objects of smaller size are created on the heap.
  • D. Smaller objects that get created on the stack can be given names.
  • E. Objects are always nameless.

  • Correct Answer
  • Objects are always nameless. 


  • More questions

    • 1. Which of the following statements is correct about Managed Code?

    • Options
    • A. Managed code is the code that is compiled by the JIT compilers.
    • B. Managed code is the code where resources are Garbage Collected.
    • C. Managed code is the code that runs on top of Windows.
    • D. Managed code is the code that is written to target the services of the CLR.
    • E. Managed code is the code that can run on top of Linux.
    • Discuss
    • 2. Which of the following is the Object Oriented way of handling run-time errors?

    • Options
    • A. OnError
    • B. HERESULT
    • C. Exceptions
    • D. Error codes
    • E. Setjump and Longjump
    • Discuss
    • 3. How many values is a subroutine capable of returning?

    • Options
    • A. Depends upon how many params arguments does it use.
    • B. Any number of values.
    • C. Depends upon how many ref arguments does it use.
    • D. 0
    • E. 1
    • Discuss
    • 4. Which of the following .NET components can be used to remove unused references from the managed heap?

    • Options
    • A. Common Language Infrastructure
    • B. CLR
    • C. Garbage Collector
    • D. Class Loader
    • E. CTS
    • Discuss
    • 5. Which of the following statements is correct about the C#.NET code snippet given below?

      struct Book
      {
          private String name; 
          private int noofpages; 
          private Single price;
      }
      Book b = new Book();

    • Options
    • A. The structure variable b will be created on the heap.
    • B. We can add a zero-argument constructor to the above structure.
    • C. When the program terminates, variable b will get garbage collected.
    • D. The structure variable b will be created on the stack.
    • E. We can inherit a new structure from struct Book.
    • Discuss
    • 6. If Sample class has a Length property with get accessor then which of the following statements will work correctly?

    • Options
    • A.
      Sample m = new Sample(); 
      m.Length = 10;
    • B.
      Sample m = new Sample(); 
      m.Length = m.Length + 20;
    • C.
      Sample m = new Sample(); 
      int l;
      l = m.Length;
    • D.
      Sample.Length = 20;
    • E.
      Console.WriteLine(Sample.Length);
    • Discuss
    • 7. A derived class can stop virtual inheritance by declaring an override as

    • Options
    • A. inherits
    • B. extends
    • C. inheritable
    • D. not inheritable
    • E. sealed
    • Discuss
    • 8. Which of the following can be declared in an interface?

      1. Properties
      2. Methods
      3. Enumerations
      4. Events
      5. Structures

    • Options
    • A. 1, 3
    • B. 1, 2, 4
    • C. 3, 5
    • D. 4, 5
    • Discuss
    • 9. Creating a derived class from a base class requires fundamental changes to the base class.

    • Options
    • A. True
    • B. False
    • Discuss
    • 10. Which of the following code snippets are the correct way to determine whether a is Odd or Even?

      1. int a;
        String res; 
        if (a % 2 == 0)
            res = "Even"; 
        else 
            res = "Odd";
      2. int a; 
        String res; 
        if (a Mod 2 == 0) 
            res = "Even"; 
        else
            res = "Odd";
      3. int a;
        Console.WriteLine(a Mod 2 == 0? "Even": "Odd");
      4. int a; 
        String res;
        a % 2 == 0? res = "Even" : res = "Odd";
        Console.WriteLine(res);

    • Options
    • A. 1, 3
    • B. 1 Only
    • C. 2, 3
    • D. 4 Only
    • E. None of these
    • Discuss


    Comments

    There are no comments.

Enter a new Comment