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.
Choose effective differences between 'Boxing' and 'Unboxing'.
- 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
- 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
- C. In 'Boxing' we need explicit conversion and in 'Unboxing' we need implicit conversion
- D. Both 'Boxing' and 'Unboxing' we need implicit conversion
Correct Answer: A
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(); } }
- A. 15, 15
- B. 10, 5
- C. 15, 5
- D. 10, 15
Correct Answer: C
Why strings are of reference type in C#.NET?
- A. To create string on stack
- B. To reduce the size of string
- C. To overcome problem of stackoverflow
- D. None of the mentioned
Correct Answer: B
Select a convenient declaration and initialization of a floating point number:
- A. float somevariable = 12.502D
- B. float somevariable = (Double) 12.502D
- C. float somevariable = (float) 12.502D
- D. float somevariable = (Decimal)12.502D
Correct Answer: C
The subset of 'int' data type is . . . . . . . .
- A. long, ulong, ushort
- B. long, ulong, uint
- C. long, float, double
- D. long, float, ushort
Correct Answer: C
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(); }
- A. 'k' should not be declared constant
- B. Expression assigned to 'k' should be constant in nature
- C. Expression (m * k) is invalid
- D. 'm' is declared in invalid format
Correct Answer: B
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(); }
- A. 1, 97
- B. 97, 65
- C. 65, 97
- D. 97, 1
Correct Answer: C
Disadvantages of Explicit Conversion are?
- A. Makes program memory heavier
- B. Results in loss of data
- C. Potentially Unsafe
- D. None of the mentioned
Correct Answer: B
What will be the output of the following C# code? static void Main(string[] args) { String name = "Dr.Gupta"; Console.WriteLine("Good Morning" + name); }
- A. Dr.Gupta
- B. Good Morning
- C. Good Morning Dr.Gupta
- D. Good Morning name
Correct Answer: C
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(); }
- A. He is playing in a grou
- B. .ground a in playing is He
- C. .dnuorg a ni gniyalp si eH
- D. He playing a
Correct Answer: C
Default Type of number without decimal is?
- A. Long Int
- B. Unsigned Long
- C. Int
- D. Unsigned Int
Correct Answer: C
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?
- A. ABCD
- B. DCBA
- C. 0 * ABCD
- D. Depends on big endian or little endian architecture
Correct Answer: D