Skip to main content

Basic Syntax And Data Types In C Sharp — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Basic Syntax And Data Types In C Sharp — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

Which Conversion function of 'Convert.TOInt32()' and 'Int32.Parse()' is efficient? i. Int32.Parse() is only used for strings and throws argument exception for null string ii. Convert.Int32() used for data types and returns directly '0' for null string

Question 2 of 40
★ FPSC ★ PPSC

For the given set of C# code, is conversion possible? static void Main(string[] args) { int a = 76; char b; b = (char)a; Console.WriteLine(b); Console.ReadLine(); }

Question 3 of 40
★ FPSC ★ PPSC

Correct way to define a value 6.28 in a variable 'pi' where value cannot be modified?

Question 4 of 40
★ FPSC ★ PPSC

Correct way to assign values to variable 'c' when int a=12, float b=3.5, int c;

Question 5 of 40
★ FPSC ★ PPSC

Correct statement about strings are?

Question 6 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? public static void Main(string[] args) { int i = 546; object o = i; int n =(int) o; o = 70; System. Console. WriteLine("The value-type value = {0}", n); System. Console. WriteLine("The object-type value = {0}", o); Console. ReadLine(); }

Question 7 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { float a = 10.553f; long b = 12L; int c; c = Convert.ToInt32(a + b); Console.WriteLine(c); }

Question 8 of 40
★ FPSC ★ PPSC

'Implicit Conversion' follows the order of conversion as per compatibility of data type as:

Question 9 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { string s1 = "Delhi"; string s2; s2 = s1.Insert (6, "Jaipur"); Console.WriteLine(s2); }

Question 10 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { { var dayCode = "MTWFS"; var daysArray = new List<string>(); var list = new Dictionary<string, string> { {"M", "Monday"}, {"T", "Tuesday"}, {"W", "Wednesday"}, {"R", "Thursday"}, {"F", "Friday"}, {"S", "Saturday"}, {"U", "Sunday"} }; for (int i = 0,max = dayCode.Length; i < max; i++) { var tmp = dayCode[i].ToString(); if (list.ContainsKey(tmp)) { daysArray.Add(list[tmp]); } } Console.WriteLine(string.Join("\n ", daysArray)); }

Question 11 of 40
★ FPSC ★ PPSC

Choose the correct type of variable scope for the following C# defined variables. class ABC { static int m; int n; void fun (int x , ref int y, out int z, int[] a) { int j = 10; } }

Question 12 of 40
★ FPSC ★ PPSC

Which is the String method used to compare two strings with each other?

Question 13 of 40
★ FPSC ★ PPSC

Correct Declaration of Values to variables 'a' and 'b'?

Question 14 of 40
★ FPSC ★ PPSC

What is the Size of 'Char' datatype?

Question 15 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { int x = 1; float y = 2. 4f; short z = 1; Console. WriteLine((float) x + y * z - (x + = (short) y) ); Console. ReadLine(); }

Question 16 of 40
★ FPSC ★ PPSC

Why does a float variable stop incrementing at number '16777216' in the following C# code? float a = 0 ; while (true) { a++; if (a > 16777216) break; }

Question 17 of 40
★ FPSC ★ PPSC

Which of the following format specifiers is used to print hexadecimal values and return value of output as Octal equivalent in C#?

Question 18 of 40
★ FPSC ★ PPSC

How many Bytes are stored by 'Long' Data type in C# .net?

Question 19 of 40
★ FPSC ★ PPSC

Verbatim string literal is better used for?

Question 20 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { float sum; int i; sum = 0.0F; for (i = 1; i <= 10; i++) { sum = sum + 1 /(float)i; } Console.WriteLine("sum =" +sum); Console.ReadLine(); }

Question 21 of 40
★ FPSC ★ PPSC

Types of 'Data Conversion' in C#?

Question 22 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { int a = 5; int b = 10; int c; Console.WriteLine(c = a-- - ++b); Console.WriteLine(b); Console.ReadLine(); }

Question 23 of 40
★ FPSC ★ PPSC

What will be the output of the following C# string? (Enter a String : BOMBAY). static void Main(string[] args) { string Str, Revstr = " "; int Length; Console.Write("Enter A String : "); Str = Console.ReadLine(); Length = Str.Length - 1; while (Length >= 0) { Revstr = Revstr + Str[Length]; Length --; } Console.WriteLine("Reverse String Is {0}", Revstr); Console.ReadLine(); }

Question 24 of 40
★ FPSC ★ PPSC

The following C# codes are? 1. Myclass class; Myclass class2 = null; 2. int i; int j = 0;

Question 25 of 40
★ FPSC ★ PPSC

Valid Size of float data type is?

Question 26 of 40
★ FPSC ★ PPSC

The Default value of Boolean Data Type is?

Question 27 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? string s1 = " I AM BEST "; string s2; s2 = s1.substring (5, 4); Console.WriteLine (s2);

Question 28 of 40
★ FPSC ★ PPSC

What is the need for 'Conversion of data type' in C#?

Question 29 of 40
★ FPSC ★ PPSC

Scope of variable is related to definition of variable as: i. Region of code within which variable value is valid and hence can be accessed. ii. No, relation with region where variable is declared its value is valid in entire scope.

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? class Program { static void Main(string[] args) { int i ; for ( i = 0; i < 5; i++) { int j = 0; j += i; Console. WriteLine(j); } Console. WriteLine(i); Console. ReadLine(); } }

Question 31 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { char c = 'g'; string s = c.ToString(); string s1 = "I am a human being" + c; Console.WriteLine(s1); Console.ReadLine(); }

Question 32 of 40
★ FPSC ★ PPSC

DIFFERENCE BETWEEN KEYWORDS 'VAR' AND 'DYNAMIC'?

Question 33 of 40
★ FPSC ★ PPSC

Which of the conversions are valid for the following C# code? static void Main(string[] args) { int a = 22; long b = 44; double c = 1.406; b = a; c = a; a = b; b = c; }

Question 34 of 40
★ FPSC ★ PPSC

Select differences between reference type and value type: i. Memory allocated to 'Value type' is from heap and reference type is from 'System. ValueType' ii. Memory allocated to 'Value type' is from 'System. ValueType' and reference type is from 'Heap' iii. Structures, enumerated types derived from 'System. ValueType' are created on stack, hence known as ValueType and all 'classes' are reference type because values are stored on heap

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { const int a = 5; const int b = 6; for (int i = 1; i <= 5; i++) { a = a * i; b = b * i; } Console.WriteLine(a); Console.WriteLine(b); Console.ReadLine(); }

Question 36 of 40
★ FPSC ★ PPSC

A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?

Question 37 of 40
★ FPSC ★ PPSC

Default Type of number without decimal is?

Question 38 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { string Name = "He is playing in a ground."; char[] characters = Name.ToCharArray(); StringBuilder sb = new StringBuilder(); for (int i = Name.Length - 1; i >= 0; --i) { sb.Append(characters[i]); } Console.Write(sb.ToString()); Console.ReadLine(); }

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following C# code? static void Main(string[] args) { String name = "Dr.Gupta"; Console.WriteLine("Good Morning" + name); }

Question 40 of 40
★ FPSC ★ PPSC

Disadvantages of Explicit Conversion are?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →