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 71–76 of 76
Topics in C# Programming
Q.71 Easy Basics & Syntax
Which of the following is a value type in C#?
A String
B Enum
C Interface
D Delegate
Correct Answer:  B. Enum
EXPLANATION

Enum is a value type in C#. String, Interface, and Delegate are reference types.

Test
Q.72 Easy Basics & Syntax
What will be the output of the following code?
string s = "Hello";
s = s + " World";
Console.WriteLine(s);
A Hello
B Hello World
C Error
D World
Correct Answer:  B. Hello World
EXPLANATION

String concatenation using '+' operator joins the two strings. s becomes 'Hello World' after the concatenation.

Test
Q.73 Easy Basics & Syntax
Which of the following is NOT a valid C# variable name?
A _myVar
B my$Var
C myVar123
D MyVar
Correct Answer:  B. my$Var
EXPLANATION

Variable names in C# can contain letters, digits, and underscores. They cannot contain special characters like '$'. The variable name must start with a letter or underscore.

Test
Q.74 Easy Basics & Syntax
Which namespace is required to use Console.WriteLine() in C#?
A System.IO
B System
C System.Console
D System.Text
Correct Answer:  B. System
EXPLANATION

Console class is part of the System namespace. You need to include 'using System;' at the beginning of your code to use Console.WriteLine().

Test
Q.75 Easy Basics & Syntax
Which keyword is used to create a class in C#?
A class
B Class
C CLASS
D struct
Correct Answer:  A. class
EXPLANATION

C# is case-sensitive. The lowercase keyword 'class' is used to define a class. 'Class' and 'CLASS' are not valid keywords.

Test
Q.76 Easy Basics & Syntax
Which of the following is the correct syntax to declare a variable in C#?
A int x = 10;
B int x: 10;
C int x
D int x == 10;
Correct Answer:  A. int x = 10;
EXPLANATION

C# uses the syntax 'type variableName = value;' to declare and initialize variables. The equals sign (=) is the assignment operator.

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