adplus-dvertising

Welcome to the Classes and Objects MCQs Page

Dive deep into the fascinating world of Classes and Objects with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Classes and Objects, a crucial aspect of C# programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Classes and Objects, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C# programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Classes and Objects. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C# programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Classes and Objects. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Classes and Objects MCQs | Page 4 of 10

Q31.
Which of the following statements are correct about objects of a user-defined class called Sample?

1. All objects of Sample class will always have exactly same data.
2. Objects of Sample class may have same or different data.
3. Whether objects of Sample class will have same or different data depends upon a Project Setting made in Visual Studio.NET.
4. Conceptually, each object of Sample class will have instance data and instance member functions of the Sample class.
5. All objects of Sample class will share one copy of member functions.
Discuss
Answer: (c).4, 5
Q32.
Which of the following statements are correct about the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{ 
    class Sample
    { 
        int i, j; 
        public void SetData(int ii, int jj)
        {
            this.i = ii;
            this.j = jj 
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample s1 = new Sample(); 
            s1.SetData(10, 2); 
            Sample s2 = new Sample(); 
            s2.SetData(5, 10); 
        } 
    } 
}
Discuss
Answer: (d).Contents of this will be different during each call to SetData().
Discuss
Answer: (d).Objects are always nameless.
Q34.
Select output for the following set of code.
class sample
 {
     public int i;
     public int[] arr = new int[10];
     public void fun(int i, int val)
     {
         arr[i] = val;
     }
 }
 class Program
 {
     static void Main(string[] args)
     {
         sample s = new sample();
         s.i = 10;
         sample.fun(1, 5);
         s.fun(1, 5);
         Console.ReadLine();
     }
 }
Discuss
Answer: (a).sample.fun(1, 5) will not work correctly
Q35.
Which of the following is used to define the member of a class externally?
Discuss
Answer: (b).::
Q36.
The operator used to access member function of a class?

a.

:

b.

::

c.

.

d.

#

Discuss
Answer: (c)..
Q37.
What is the most specified using class declaration ?
Discuss
Answer: (c).type & scope
Q38.
Select the output for the following set of code :
class sample
  {
      public int i;
      public int j;
      public void fun(int i, int j)
      {
          this.i = i;
          this.j = j;
      }
  }
  class Program
  {
      static void Main(string[] args)
      {
          sample s = new sample();
          s.i = 1;
          s.j = 2;
          s.fun(s.i, s.j);
          Console.WriteLine(s.i + " " + s.j);
          Console.ReadLine();
      }
  }
Discuss
Answer: (c).1 2
Discuss
Answer: (d).All of the mentioned
Q40.
“A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse.In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data.”
Discuss
Answer: (d).Encapsulation
Page 4 of 10

Suggested Topics

Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!