Explore topic-wise MCQs in C Sharp Programming.

This section includes 155 Mcqs, each offering curated multiple-choice questions to sharpen your C Sharp Programming knowledge and support exam preparation. Choose a topic below to get started.

151.

Creating empty structures is allowed in C#.NET.

A. 1
B.
Answer» C.
152.

Which of the following is the correct way to define a variable of the type struct Emp declared below? struct Emp { private String name; private int age; private Single sal; } Emp e(); e = new Emp(); Emp e = new Emp; Emp e; e = new Emp; Emp e = new Emp(); Emp e;

A. 1, 3
B. 2, 5
C. 4, 5
D. 1, 2, 4
Answer» D. 1, 2, 4
153.

Which of the following are true about classes and struct? A class is a reference type, whereas a struct is a value type. Objects are created using new, whereas structure variables can be created either using new or without using new. A structure variable will always be created slower than an object. A structure variable will die when it goes out of scope. An object will die when it goes out of scope.

A. 1, 2, 4
B. 3, 5
C. 2, 4
D. 3, 4, 5
Answer» B. 3, 5
154.

Which of the following will be the correct output for the C#.NET program given below? namespace IndiabixConsoleApplication { struct Sample { public int i; } class MyProgram { static void Main() { Sample x = new Sample(); x.i = 10; fun(x); Console.Write(x.i + " "); } static void fun(Sample y) { y.i = 20; Console.Write(y.i + " "); } } }

A. 10 20
B. 10 10
C. 20 10
D. 20 20
Answer» D. 20 20
155.

Which of the following is the correct way of setting values into the structure variable e defined below? struct Emp { public String name; public int age; public Single sal; } Emp e = new Emp();

A. e.name = "Amol"; e.age = 25; e.sal = 5500;
B. With e { .name = "Amol"; .age = 25; .sal = 5500; }
C. With emp e { .name = "Amol"; .age = 25; .sal = 5500; }
D. e -> name = "Amol"; e -> age = 25; e -> sal = 5500;
Answer» B. With e { .name = "Amol"; .age = 25; .sal = 5500; }