Home » Aptitude Questions and Answers » C# Aptitude Questions and Answers
This section contains aptitude questions and answers on C# data types (set 1).
Correct answer: 2System.Int32
int is an alias of System.Int32 type, it takes 32 bits in the memory.
Correct answer: 1System.Char
char is an alias of System.Char type, it takes 2 bytes space in the memory. Read more: char keyword in C#.
Correct answer: 30 to 255
byte is an alias of System.Byte type, it takes 1 byte space in the memory. Read more: byte keyword in C#.
Correct answer: 1-128 to +127
sbyte stands for signed byte, it's an alias of System.SByte, it takes 1-byte space in the memory. Read more: sbyte keyword in C#.
static void Main(string[] args) { byte a = 10; byte b = 20; byte sum = a + b; Console.WriteLine(sum); }
Correct answer: 2Compilation error: Cannot implicitly convert type 'int' to 'byte'
By default, Arithmetic operation evaluates to 'int'.
To fix this problem, cast the expression as byte sum = (byte) (a+b);
static void Main(string[] args) { sbyte a = -10; sbyte b = 20; sbyte sum = a + b; Console.WriteLine(sum); }
Correct answer: 2Compilation error: Cannot implicitly convert type 'int' to 'sbyte'
To fix this problem, cast the expression as sbyte sum = (sbyte) (a+b);
Correct answer: 3-2,147,483,648 to 2,147,483,647
The correct range of int is from -2,147,483,648 to 2,147,483,647
Correct answer: 40 to 4,294,967,295
The correct range of uint is from 0 to 4,294,967,295
Correct answer: 1-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
The correct range of long is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
Correct answer: 20 to 18,446,744,073,709,551,615
The correct range of long is from 0 to 18,446,744,073,709,551,615
Correct answer: 1Anders Hejlsberg
C# is developed by Anders Hejlsberg.
Correct answer: 22 bytes
If we declare a variable of char type, it occupies 2 bytes space in memory.
Correct answer: 1System.Single
In C#.NET System.Single is the equivalent .NET type of float type.
Correct answer: 4System.float
System.float is not available of .NET framework.
Correct answer: 2System.Double
In C#.NET System.Double is the equivalent .NET type of double type.
Correct answer: 3System.Decimal
In C#.NET System.Decimal is the equivalent .NET type of decimal type.
Correct answer: 34 bytes
In C# the size of a float variable is 4 bytes.
Correct answer: 48 bytes
In C# the size of a double variable is 8 bytes.
Correct answer: 216 bytes
In C# the size of a decimal variable is 16 bytes.
Correct answer: 2Double
By default, a real number is Double.
Correct answer: 1'f' or 'F'
By default, a real number is Double. To use real number for float type, we need to use 'F'/'f' in suffix of real number.
Correct answer: 2'M' or 'm'
By default, a real number is Double. To use real number for decimal type, we need to use 'M'/'m' in suffix of real number.
Correct answer: 2Up to 7 digits
The precision of float numbers in C# is up to 7 digits.
Correct answer: 1Up to 15 digits
The precision of double numbers in C# is up to 15 digits.
Correct answer: 3Up to 28 digits
The precision of decimal numbers in C# is up to 28 digits.
Comments and Discussions!
Load comments ↻