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

Q61.
What is output of the code?
static void Main(string[] args)
{
    Mul();
    m();
    Console.ReadLine();
}
static void Mul()
{
    Console.WriteLine("4");
}
static void m()
{
    Console.WriteLine("3");
    Mul();
}
Discuss
Answer: (c).4 3 4
Q62.
What is the output of the code ?
static void Main(string[] args)
 {
     m();
     Console.ReadLine();
 }
 static void m()
 {
     Console.WriteLine("HI");
     m();
 }
Discuss
Answer: (c).Stack overflow exception
Q63.
When a function fun() is to receive an int, a single & a double and it is to return a decimal, then the correct way of defining this function is?
Discuss
Answer: (b).static decimal fun(int i, single, double k)
{

}
Q64.
What is the output for the following set of code :
static void Main(string[] args)
 {
     int i = 10;
     double d = 35.78;
     fun(i);
     fun(d);
     Console.ReadLine();
 }
 static void fun(double d)
 {
     Console.WriteLine(d);
 }
Discuss
Answer: (c).10
35.78
Q65.
How many values does a function return?
Discuss
Answer: (c).1
Q66.
Output for the following set of code :
static void Main(string[] args)
 {
     int y = 3;
     y++;
     if (y <= 5)
     { 
         Console.WriteLine("hi");
         Main(args);
     }
     Console.ReadLine();
 }
Discuss
Answer: (c).Stack overflow exception
Discuss
Answer: (a).public int cube(int x)
{
return (x + x);
}
Q68.
What is the output for selective code ?
public static void Main(string[] args)
 {
     p();
     void p()
     {
         Console.WriteLine("hi");
     }
 }
Discuss
Answer: (a).Compile time error
Q69.
Number of constructors a class can define is ?
Discuss
Answer: (c).Any number
Q70.
Correct way of defining constructor of the given class as and when objects of classes are created is:

maths s1 = new maths();
maths s2 = new maths(5, 5.4f);
a) public maths(int pp, single tt)
   {
       p = pp;
       t = tt;
   }

b) sample s;

c) public sample()
   {
      p = 0;
      t = 0.0f;
   }
  public sample(int pp, single tt)
  {
       p = pp;
       t = tt;
  }

d) s = new sample();

a.

a

b.

b

c.

c

d.

d

Discuss
Answer: (a).a
Page 7 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!