C# - Datatypes Questions and Answers

Practice Mode
Showing 10 of 42 questions
Q21
Which of the following is a reference data type?
  • A int
  • B double
  • C char
  • D string Explanation: String is a reference type in C#.
Answer: Option D
Explanation: String is a reference type in C#.
Q22
What is the size of int data type in C#?
  • A 2 bytes
  • B 4 bytes Explanation: An int occupies 4 bytes in C#.
  • C 8 bytes
  • D Depends on system
Answer: Option B
Explanation: An int occupies 4 bytes in C#.
Q23
Which data type can store decimal values with high precision?
  • A float
  • B double
  • C decimal Explanation: Decimal provides higher precision, mainly used in financial calculations.
  • D long
Answer: Option C
Explanation: Decimal provides higher precision, mainly used in financial calculations.
Q24
Which keyword is used to define a user-defined data type in C#?
  • A struct
  • B enum
  • C class
  • D All of the above Explanation: Struct, enum, and class all define user-defined data types.
Answer: Option D
Explanation: Struct, enum, and class all define user-defined data types.
Q25
What is the size of char data type in C#?
  • A 1 byte
  • B 2 bytes Explanation: Char stores Unicode characters and occupies 2 bytes.
  • C 4 bytes
  • D 8 bytes
Answer: Option B
Explanation: Char stores Unicode characters and occupies 2 bytes.
Q26
Which data type should be used to store a large whole number?
  • A int
  • B short
  • C long Explanation: Long is used for storing large integer values.
  • D byte
Answer: Option C
Explanation: Long is used for storing large integer values.
Q27
Which of the following is NOT a built-in data type in C#?
  • A float
  • B string
  • C object
  • D variant Explanation: Variant is not a data type in C#.
Answer: Option D
Explanation: Variant is not a data type in C#.
Q28
Which data type is the base type of all data types in C#?
  • A string
  • B object Explanation: Object is the base class for all types in C#.
  • C dynamic
  • D var
Answer: Option B
Explanation: Object is the base class for all types in C#.
Q29
Which keyword allows implicit type inference in C#?
  • A dynamic
  • B object
  • C var Explanation: var lets the compiler infer the type at compile time.
  • D auto
Answer: Option C
Explanation: var lets the compiler infer the type at compile time.
Q30
Which data type stores a single Unicode character?
  • A string
  • B char Explanation: Char represents a single Unicode character.
  • C byte
  • D bool
Answer: Option B
Explanation: Char represents a single Unicode character.
Questions and Answers for Competitive Exams Various Entrance Test