Home Subjects C# Programming

C# Programming

C# and .NET for campus placement

76 Q 4 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 51–60 of 76
Topics in C# Programming
Q.51 Easy Basics & Syntax
What will be the result of: Console.WriteLine(10 / 3);
A 3.33333
B 3.33
C 3
D 3.0
Correct Answer:  C. 3
EXPLANATION

Since both 10 and 3 are integers, integer division occurs, resulting in 3 (the decimal part is truncated).

Test
Q.52 Easy Basics & Syntax
Which of the following correctly declares and initializes an array in C#?
A int[] arr = new int[5] {1, 2, 3, 4, 5};
B int arr[5] = {1, 2, 3, 4, 5};
C int[] arr(5) = {1, 2, 3, 4, 5};
D array int[] arr = new int[5];
Correct Answer:  A. int[] arr = new int[5] {1, 2, 3, 4, 5};
EXPLANATION

Option A is the correct C# syntax. Option B is C-style, Option C has wrong syntax, and Option D has incorrect keyword placement.

Test
Q.53 Easy Basics & Syntax
Which of the following is NOT a value type in C#?
A int
B string
C float
D bool
Correct Answer:  B. string
EXPLANATION

string is a reference type in C#, while int, float, and bool are value types.

Test
Q.54 Easy Basics & Syntax
What is the output of: bool result = (5 > 3) && (3 < 2); Console.WriteLine(result);
A true
B false
C null
D Error
Correct Answer:  B. false
EXPLANATION

The && operator requires both conditions to be true. (5 > 3) is true, but (3 < 2) is false. Since one condition is false, the entire expression evaluates to false.

Test
Q.55 Easy Basics & Syntax
Which statement correctly describes value types in C#?
A Value types are stored on the heap
B Value types are stored on the stack
C Value types require null checking
D Value types can be inherited
Correct Answer:  B. Value types are stored on the stack
EXPLANATION

Value types (int, double, struct, etc.) are stored on the stack memory. Reference types (class, interface) are stored on the heap. Value types don't require null checks like reference types.

Test
Q.56 Easy Basics & Syntax
What is the default access modifier for a class member in C# if not explicitly specified?
A public
B private
C protected
D internal
Correct Answer:  B. private
EXPLANATION

The default access modifier for class members in C# is 'private'. This means the member is only accessible within the same class unless explicitly specified otherwise.

Test
Q.57 Easy Basics & Syntax
In C#, which keyword is used to declare a variable that cannot be changed after initialization?
A const
B static
C readonly
D volatile
Correct Answer:  A. const
EXPLANATION

The 'const' keyword declares a constant whose value cannot be modified. Both 'const' and 'readonly' prevent changes, but 'const' is compile-time constant while 'readonly' is runtime constant.

Test
Q.58 Easy Basics & Syntax
What will be printed when the following code executes?
string str = "Hello";
str = str + " World";
Console.WriteLine(str.Length);
A 5
B 11
C 6
D 10
Correct Answer:  B. 11
EXPLANATION

"Hello" has 5 characters. After concatenation with " World" (6 characters including space), the total length is 11.

Test
Q.59 Easy Basics & Syntax
In C#, what is the correct syntax to declare a nullable integer?
A int? number;
B int* number;
C nullable number;
D int[?] number;
Correct Answer:  A. int? number;
EXPLANATION

The '?' suffix is used to declare nullable value types in C#. int? means an integer that can also hold null values.

Test
Q.60 Easy Basics & Syntax
Which namespace must be included to use LINQ in C#?
A System.Collection
B System.Linq
C System.Data
D System.Threading
Correct Answer:  B. System.Linq
EXPLANATION

LINQ (Language Integrated Query) is available in the System.Linq namespace introduced in .NET 3.5.

Test
IGET
IGET AI
Online · Exam prep assistant
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips