Commerce

Basic Syntax And Data Types In C Sharp MCQs

Practice Basic Syntax And Data Types In C Sharp MCQs for competitive exams.

Basic Syntax And Data Types In C Sharp MCQs

Practice questions from this topic.

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(); }

  1. A. BOMBA
  2. B. YABMOB
  3. C. BOMAYB
  4. D. YABMO
Report Error

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(); }

  1. A. -7, 10
  2. B. -5, 11
  3. C. -6, 11
  4. D. 15, 11
Report Error

Types of 'Data Conversion' in C#?

  1. A. Implicit Conversion
  2. B. Explicit Conversion
  3. C. Implicit Conversion and Explicit Conversion
  4. D. None of the mentioned
Report Error

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(); }

  1. A. 2.000
  2. B. 2.910
  3. C. 2.928
  4. D. 3.000
Report Error

Verbatim string literal is better used for?

  1. A. Convenience and better readability of strings when string text consist of backlash characters
  2. B. Used to initialize multi-line strings
  3. C. To embed a quotation mark by using double quotation marks inside a verbatim string
  4. D. All of the mentioned
Report Error

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

  1. A. 8
  2. B. 4
  3. C. 2
  4. D. 1
Report Error

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

  1. A. %hx for small case letters and %HX for capital letters
  2. B. %x for small case letters and %X for capital letters
  3. C. No ease of doing it. C# don't provides specifier like %x or %O to be used with ReadLine() OR WriteLine(). We have to write our own function
  4. D. %Ox for small case letters and %OX for capital letters
Report Error

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; }

  1. A. Sign and Exponent for '16777217' is same as for '16777216'
  2. B. Mantissa is different for '16777216' and '16777217'
  3. C. Sign and Exponent for '16777217' is different from '16777216'
  4. D. None of the mentioned
Report Error

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(); }

  1. A. 0.4000004
  2. B. 0.4000023
  3. C. 0.0400021
  4. D. 0.4000001
Report Error

What is the Size of 'Char' datatype?

  1. A. 8 bit
  2. B. 12 bit
  3. C. 16 bit
  4. D. 20 bit
Report Error

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

  1. A. int a = 32, b = 40.6
  2. B. int a = 42; b = 40
  3. C. int a = 32; int b = 40
  4. D. int a = b = 42
Report Error

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

  1. A. 0, 1, 6, 18, 40
  2. B. 0, 1, 5, 20, 30
  3. C. Compile time error
  4. D. 0, 1, 2, 3, 4, 5
Report Error