CommerceBasic 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(); }
- A. BOMBA
- B. YABMOB
- C. BOMAYB
- D. YABMO
Correct Answer: B
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(); }
- A. -7, 10
- B. -5, 11
- C. -6, 11
- D. 15, 11
Correct Answer: C
Types of 'Data Conversion' in C#?
- A. Implicit Conversion
- B. Explicit Conversion
- C. Implicit Conversion and Explicit Conversion
- D. None of the mentioned
Correct Answer: B
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(); }
- A. 2.000
- B. 2.910
- C. 2.928
- D. 3.000
Correct Answer: C
Verbatim string literal is better used for?
- A. Convenience and better readability of strings when string text consist of backlash characters
- B. Used to initialize multi-line strings
- C. To embed a quotation mark by using double quotation marks inside a verbatim string
- D. All of the mentioned
Correct Answer: D
How many Bytes are stored by 'Long' Data type in C# .net?
- A. 8
- B. 4
- C. 2
- D. 1
Correct Answer: A
Which of the following format specifiers is used to print hexadecimal values and return value of output as Octal equivalent in C#?
- A. %hx for small case letters and %HX for capital letters
- B. %x for small case letters and %X for capital letters
- 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
- D. %Ox for small case letters and %OX for capital letters
Correct Answer: C
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; }
- A. Sign and Exponent for '16777217' is same as for '16777216'
- B. Mantissa is different for '16777216' and '16777217'
- C. Sign and Exponent for '16777217' is different from '16777216'
- D. None of the mentioned
Correct Answer: B
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(); }
- A. 0.4000004
- B. 0.4000023
- C. 0.0400021
- D. 0.4000001
Correct Answer: D
What is the Size of 'Char' datatype?
- A. 8 bit
- B. 12 bit
- C. 16 bit
- D. 20 bit
Correct Answer: C
Correct Declaration of Values to variables 'a' and 'b'?
- A. int a = 32, b = 40.6
- B. int a = 42; b = 40
- C. int a = 32; int b = 40
- D. int a = b = 42
Correct Answer: C
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(); }
- A. 0, 1, 6, 18, 40
- B. 0, 1, 5, 20, 30
- C. Compile time error
- D. 0, 1, 2, 3, 4, 5
Correct Answer: C