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 10 of 10

Explore more Topics under C# programming

Q91.
Which of these base class are accessible to the derived class members?
Discuss
Answer: (b).protected
Q92.
What will be the output of the given code snippet?
class access
 {
     public int x;
     private int y;
     public  void cal(int a, int b)
     {
         x = a + 1;
         y = b;
     }
 }    
 class Program
 {
     static void Main(string[] args)
     {
         access obj = new access();   
         obj.cal(2, 3);
         Console.WriteLine(obj.x + " " + obj.y);     
     }
 }
Discuss
Answer: (d).Compile time error
Q93.
What will be the output of the given code snippet?
class access
{
    public int x;
    private int y;
    public  void cal(int a, int b)
    {
        x = a + 1;
        y = b;
    }
    public  void print() 
   {
       Console.WriteLine(" " + y);     
   } 
}    
class Program
{
    static void Main(string[] args)
    {
        access obj = new access();   
        obj.cal(2, 3);
        Console.WriteLine(obj.x);
        obj.print();
        Console.ReadLine();
    }
}
Discuss
Answer: (b).3 3
Q94.
What will be the output of the following set of code?
class sum   
 {
     public int x;
     public int y;
     public  int add (int a, int b)
    {
        x = a + b;
        y = x + b;
        return 0;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        sum obj1 = new sum();
        sum obj2 = new sum();   
        int a = 2;
        obj1.add(a, a + 1);
        obj2.add(5, a);
        Console.WriteLine(obj1.x + "  " + obj2.y);     
        Console.ReadLine();
    }
}
Discuss
Answer: (b).5, 9
Q95.
What will be the output of the following set of code?
class static_out
{
    public static int x;
    public  static int y;
    public int add(int a, int b)
    {
        x = a + b;
        y = x + b;
        return 0;
    }
}    
class Program
{
    static void Main(string[] args)
    {
        static_out obj1 = new static_out();
        static_out obj2 = new static_out();   
        int a = 2;
        obj1.add(a, a + 1);
        obj2.add(5, a);
        Console.WriteLine(static_out.x + " " + static_out.y );     
        Console.ReadLine();
    }
}
Discuss
Answer: (c).7 9
Q96.
Which of these access specifiers must be used for class so that it can be inherited by another sub class?
Discuss
Answer: (a).public
Discuss
Answer: (c).private members of class can be inherited by a sub class, and become protected members in sub class
Q98.
What will be the output of code snippet?
class test
 {
     public   int a;
     public  int b;
     public  test(int i, int j)
     {
         a = i;
         b = j;
     }
     public void meth(test o)
     {
         o.a *= 2;
         o.b /= 2;
     }
 }    
 class Program
 {
     static void Main(string[] args)
     {
         test obj = new test(10, 20);
         obj.meth(obj);
         Console.WriteLine(obj.a + " " + obj.b);    
         Console.ReadLine();
     }
 }
Discuss
Answer: (c).20, 10
Discuss
Answer: (d).public, private, protected, internal, protected internal
Page 10 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!