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

Explore more Topics under C# programming

Q11.
Which of the following statements are correct about the C#.NET code snippet given below?

class Sample
{
    static int i;
    int j;
    public void proc1()
    {
        i = 11; 
        j = 22;
    }
    public static void proc2()
    {
        i = 1;
        j = 2;
    }
    static Sample()
    {
        i = 0; 
        j = 0;
    }
}
Discuss
Answer: (b).proc1() can initialize i as well as j.
Discuss
Answer: (b).There is one common garbage collector for all programs.
Q13.
Is it possible for you to prevent an object from being created by using zero argument constructor?
Discuss
Answer: (a).Yes
Discuss
Answer: (d).Static functions are invoked using class.
Q15.
What will be the output of the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{ 
    class Sample
    { 
        static Sample()
        { 
            Console.Write("Sample class ");
        }
        public static void Bits1()
        { 
            Console.Write("Bits1 method ");
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample.Bits1();
        } 
    } 
}
Discuss
Answer: (a).Sample class Bits1 method
Discuss
Answer: (c).A constructor can be a static constructor.
Q17.
What will be the output of the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{
    class Sample
    { 
        public static void fun1()
        { 
            Console.WriteLine("Bits1 method");
        }
        public void fun2()
        { 
            fun1(); 
            Console.WriteLine("Bits2 method");
        }
        public void fun2(int i)
        { 
            Console.WriteLine(i);
            fun2(); 
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample s = new Sample(); 
            Sample.fun1(); 
            s.fun2(123);
        } 
    } 
}
Discuss
Answer: (a).Bits1 method
123
Bitsl method
Bits2 method
Q18.
Which of the following statements is correct about the C#.NET code snippet given below?

class Student s1, s2; // Here 'Student' is a user-defined class.
s1 = new Student(); 
s2 = new Student();
Discuss
Answer: (c).Contents of the two objects created will be exactly same.
Q19.
Which of the following statements is correct about the C#.NET code snippet given below?

class Sample
{
    private int i;
    public Single j;
    private void DisplayData()
    {
        Console.WriteLine(i + " " + j);
    }
    public void ShowData()
    {
        Console.WriteLine(i + " " + j);
    }
}
Discuss
Answer: (d).There is no error in this class.
Q20.
Which of the following statements are correct?

1. Instance members of a class can be accessed only through an object of that class.
2. A class can contain only instance data and instance member function.
3. All objects created from a class will occupy equal number of bytes in memory.
4. A class can contain Friend functions.
5. A class is a blueprint or a template according to which objects are created.
Discuss
Answer: (a).1, 3, 5

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!