Datatypes Questions

Practice Datatypes MCQs with answers and explanations. Page 1 of 1.

Category
C# Programming
Topic
Datatypes
Page
1 / 1
Mode
Practice

Questions

Open any question to view the answer and explanation.

C#.NET — What is the default value of the Boolean type (bool)?
Open
View answer
C#.NET — Identify the value types among the following: Integer, Array, Single, String, Long.
Open
View answer
C#.NET — Initialize two variables i and j to 10 each: which statements are valid?
Open
View answer
C#.NET — Evaluate the expression and predict the output. int x = 1; float y = 1.1f; short z = 1; Console.WriteLine((float)x + y * z - (x += (short)y));
Open
View answer
C#.NET — Set a constant value 3.14 for pi so it cannot be modified later: choose the correct construct.
Open
View answer
C#.NET — Understand arithmetic promotions and overflow behavior. Given: short s1 = 20; short s2 = 400; int a; a = s1 * s2; What happens?
Open
View answer
C#.NET — Which of the following is NOT an integer type in the sense used by this question?
Open
View answer
C#.NET — Data type rules: choose the correct set of statements. Assigning an integer literal to a byte variable that exceeds byte range causes a compilation error. Non-literal numeric types of larger storage size cannot be implicitly converted to byte. Byte cannot be implicitly converted to float. A char can be implicitly converted only to int. We can cast integral character codes explicitly.
Open
View answer
In C#.NET data types and memory representation, what is the storage size of the built-in Decimal (System.Decimal) value type? Choose the most accurate size in bytes.
Open
View answer
Type conversion in C#.NET and VB-style helpers: which statement is correct? Consider these claims about conversions and literals: • Information is never lost during narrowing conversions. • The CInteger() helper can convert a Single to an Integer. • Widening conversions take place automatically. • Assigning an Integer to an Object variable is called unboxing. • The literal 3.14 can be treated as Decimal using the suffix F.
Open
View answer
Boxing, unboxing, and nullability in C#.NET — identify the correct statements. 1) We can assign values of any type to variables of type object. 2) Converting a value type to object is called unboxing. 3) Converting an object back to a value type is called boxing. 4) A Boolean variable cannot have a value of null (without Nullable). 5) When a value type is boxed, a new object must be allocated and constructed on the managed heap.
Open
View answer
Integral types in C#.NET — which of the following is an 8-byte signed integer type?
Open
View answer
C#.NET data types — which statements are correct? 1) Each value type has an implicit default constructor that initializes the type's default value. 2) A value type can contain the null value. 3) All value types implicitly derive from System.ValueType. 4) It is not essential that local variables be definitely assigned before use. 5) Variables of reference types store references (not the actual object data).
Open
View answer
Unsigned vs signed storage in C#.NET — which of the following types does not store a sign bit?
Open
View answer
Given the declarations below, which statement correctly assigns the value 33 to variable c in C#? byte a = 11, b = 22, c;
Open
View answer
What is the correct storage size for the Decimal (System.Decimal) data type in C#.NET? Select the best answer in bytes.
Open
View answer
C#.NET types and the Common Type System (CTS) — which statements are correct? 1) Every data type is either a value type or a reference type. 2) Value types are always created on the heap. 3) Reference types are always created on the stack. 4) Mapping of each value type to a CTS type facilitates interoperability. 5) Every reference type maps to a CTS type.
Open
View answer

Practice smarter

Solve a few questions daily and revisit weak topics regularly to improve accuracy.