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

Explore more Topics under C# programming

Discuss
Answer: (a).A constructor can be used to set default values and limit instantiation.
Q2.
Which of the following statements is correct about the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{ 
    class Sample
    { 
        public int func()
        {
            return 1;
        } 
        public Single func()
        { 
            return 2.4f ;
        } 
    } 
    class Program
    { 
        static void Main(string[ ] args)
        {
            Sample s1 = new Sample(); 
            int i;
            i = s1.func(); 
            Single j; 
            j = s1.func(); 
        } 
    } 
}
Discuss
Answer: (c).func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.
Q3.
Which of the following ways to create an object of the Sample class given below will work correctly?

class Sample
{
    int i;
    Single j;
    double k;
    public Sample (int ii, Single jj, double kk)
    {
        i = ii;
        j = jj;
        k = kk;
    } 
}
Discuss
Answer: (d).Sample s3 = new Sample(10, 1.2f, 2.4);
Q4.
Which of the following statements are correct about static functions?

1. Static functions can access only static data.
2. Static functions cannot call instance functions.
3. It is necessary to initialize static data.
4. Instance functions can call static functions and access static data.
5. this reference is passed to static functions.
Discuss
Answer: (a).1, 2, 4
Discuss
Answer: (d).If we do not provide a constructor, then the compiler provides a zero-argument constructor.
Q6.
Which of the following is the correct way to define the constructor(s) of the Sample class if we are to create objects as per the C#.NET code snippet given below?

Sample s1 = new Sample(); 
Sample s2 = new Sample(9, 5.6f);
Discuss
Answer: (a).public Sample()
{
i = 0;
j = 0.0f;
}
public Sample (int ii, Single jj)
{
i = ii;
j = jj;
}
Q7.
In which of the following should the methods of a class differ if they are to be treated as overloaded methods?

1. Type of arguments
2. Return type of methods
3. Number of arguments
4. Names of methods
5. Order of arguments
Discuss
Answer: (c).1, 3, 5
Q8.
Can static procedures access instance data?
Discuss
Answer: (b).No
Q9.
Which of the following statements are correct about constructors in C#.NET?

1. Constructors cannot be overloaded.
2. Constructors always have the name same as the name of the class.
3. Constructors are never called explicitly.
4. Constructors never return any value.
5. Constructors allocate space for the object in memory.
Discuss
Answer: (b).2, 3, 4
Discuss
Answer: (b).Only once.
Page 1 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!