Commerce

Classes And Objects In C Sharp MCQs

Practice Classes And Objects In C Sharp MCQs for competitive exams.

Classes And Objects In C Sharp MCQs

Practice questions from this topic.

If base class consist of two private integers, one static integer and derived class consist of two static integers and one private integer. What would be the size of derived class object?

  1. A. size of object depends on sizes of its non static data members
  2. B. size of a derived class object is sum of sizes of non static data members of base class and derived class
  3. C. size of object is calculated using sizeof() method
  4. D. none of the mentioned
Report Error

Which of the following keyword is used to overload user defined types by defining static member functions?

  1. A. op
  2. B. opoverload
  3. C. operator
  4. D. operatoroverload
Report Error

Which of the following is the correct way to settle down values into the structure variable 'e' defined in the following C# code snippet? struct emp { public String name; public int age; public Single sal; } emp e = new emp();

  1. A. e.name = "Jone"; e.age = 24; e.sal = 200
  2. B. With emp e { .name = "Jone"; .age = 24; .sal = 200; }
  3. C. name = "Jone"; age = 24; sal = 200
  4. D. All of the mentioned
Report Error

What is the keyword used to create an instance of a class in C#?

  1. A. object
  2. B. new
  3. C. instance
  4. D. None of the above
Report Error

What is the concept in OOP that allows a class to have more than one constructor in C#?

  1. A. Method Overriding
  2. B. Constructor Overriding
  3. C. Method Overloading
  4. D. Constructor Overloading
Report Error

In C#, what is the method called automatically when an object is created to initialize the object's state?

  1. A. Constructor
  2. B. Destructor
  3. C. Initialize
  4. D. Instantiate
Report Error

In C#, which keyword is used to explicitly call a base class constructor from a derived class constructor?

  1. A. parent
  2. B. this.base
  3. C. super
  4. D. base
Report Error

What is the access modifier used to declare a class member that is accessible only within its own class and any class derived from it in C#?

  1. A. internal
  2. B. protected
  3. C. protected internal
  4. D. private internal
Report Error

In C#, what is the method used to explicitly release resources allocated by an object?

  1. A. Free
  2. B. Dispose
  3. C. Deallocate
  4. D. None of the above
Report Error

In C#, which keyword is used to declare a method that can be overridden by a derived class?

  1. A. sealed
  2. B. abstract
  3. C. override
  4. D. virtual
Report Error

What is the default access modifier for a class in C# if no access modifier is specified?

  1. A. internal
  2. B. private
  3. C. public
  4. D. protected
Report Error

In C#, what is the method called automatically when an object is no longer referenced and is ready to be removed from memory?

  1. A. Destructor
  2. B. Finalize
  3. C. Dispose
  4. D. Garbage Collector
Report Error