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.

Choose effective differences between 'Boxing' and 'Unboxing'.

  1. A. 'Boxing' is the process of converting a value type to the reference type and 'Unboxing' is the process of converting reference to value type
  2. B. 'Boxing' is the process of converting a reference type to value type and 'Unboxing' is the process of converting value type to reference type
  3. C. In 'Boxing' we need explicit conversion and in 'Unboxing' we need implicit conversion
  4. D. Both 'Boxing' and 'Unboxing' we need implicit conversion
Report Error

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

  1. A. 15, 15
  2. B. 10, 5
  3. C. 15, 5
  4. D. 10, 15
Report Error

Why strings are of reference type in C#.NET?

  1. A. To create string on stack
  2. B. To reduce the size of string
  3. C. To overcome problem of stackoverflow
  4. D. None of the mentioned
Report Error

Select a convenient declaration and initialization of a floating point number:

  1. A. float somevariable = 12.502D
  2. B. float somevariable = (Double) 12.502D
  3. C. float somevariable = (float) 12.502D
  4. D. float somevariable = (Decimal)12.502D
Report Error

The subset of 'int' data type is . . . . . . . .

  1. A. long, ulong, ushort
  2. B. long, ulong, uint
  3. C. long, float, double
  4. D. long, float, ushort
Report Error

What will be the error in the following C# code? Static Void Main(String[] args) { const int m = 100; int n = 10; const int k = n / 5 * 100 * n ; Console.WriteLine(m * k); Console.ReadLine(); }

  1. A. 'k' should not be declared constant
  2. B. Expression assigned to 'k' should be constant in nature
  3. C. Expression (m * k) is invalid
  4. D. 'm' is declared in invalid format
Report Error

What will be the output of the following C# code conversion? static void Main(string[] args) { char a = 'A'; string b = "a"; Console.WriteLine(Convert.ToInt32(a)); Console.WriteLine(Convert.ToInt32(Convert.ToChar(b))); Console.ReadLine(); }

  1. A. 1, 97
  2. B. 97, 65
  3. C. 65, 97
  4. D. 97, 1
Report Error

Disadvantages of Explicit Conversion are?

  1. A. Makes program memory heavier
  2. B. Results in loss of data
  3. C. Potentially Unsafe
  4. D. None of the mentioned
Report Error

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

  1. A. Dr.Gupta
  2. B. Good Morning
  3. C. Good Morning Dr.Gupta
  4. D. Good Morning name
Report Error

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

  1. A. He is playing in a grou
  2. B. .ground a in playing is He
  3. C. .dnuorg a ni gniyalp si eH
  4. D. He playing a
Report Error

Default Type of number without decimal is?

  1. A. Long Int
  2. B. Unsigned Long
  3. C. Int
  4. D. Unsigned Int
Report Error

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?

  1. A. ABCD
  2. B. DCBA
  3. C. 0 * ABCD
  4. D. Depends on big endian or little endian architecture
Report Error