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.
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 5 of 10
Explore more Topics under C# programming
class z
{
public int X;
public int Y;
public const int c1 = 5;
public const int c2 = c1 * 25;
public void set(int a, int b)
{
X = a;
Y = b;
}
}
class Program
{
static void Main(string[] args)
{
z s = new z();
s.set(10, 20);
Console.WriteLine(s.X + " " + s.Y);
Console.WriteLine(z.c1 + " " + z.c2);
Console.ReadLine();
}
}
5 125
class name
class z
{
public string name1;
public string address;
public void show()
{
Console.WriteLine("{0} is in city{1}", name1, " ", address);
}
}
class Program
{
static void Main(string[] args)
{
z n = new z();
n.name1 = "harsh";
n.address = "new delhi";
n.show();
Console.ReadLine();
}
}
csharp abc;
abc = new charp();
class test
{
public void print()
{
Console.WriteLine("Csharp:");
}
}
class Program
{
static void Main(string[] args)
{
test t;
t.print();
Console.ReadLine();
}
}
static void Main(string[] args)
{
int a = 5;
fun1 (ref a);
Console.WriteLine(a);
Console.ReadLine();
}
static void fun1(ref int a)
{
a = a * a;
}
static void Main(string[] args)
{
int[] arr = new int[] {1 ,2 ,3 ,4 ,5 };
fun1(ref arr);
Console.ReadLine();
}
static void fun1(ref int[] array)
{
for (int i = 0; i < array.Length; i++)
{
array[i] = array[i] + 5;
Console.WriteLine(array[i] + " ");
}
}
static void Main(string[] args)
{
int a = 10 , b = 20;
Console.WriteLine("Result before swap is: "+ a +" "+b);
swap(ref a, ref b);
Console.ReadLine();
}
static void swap(ref int i, ref int j)
{
int t;
t = i;
i = j;
j = t;
Console.WriteLine("Result after swap is:"+ i +" "+j);
}
Result after swap is:20 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!