C# Programming - Datatypes - Discussion

Discussion Forum : Datatypes - General Questions (Q.No. 13)
13.
Which of the following statements are correct about data types?
  1. Each value type has an implicit default constructor that initializes the default value of that type.
  2. It is possible for a value type to contain the null value.
  3. All value types are derived implicitly from System.ValueType class.
  4. It is not essential that local variables in C# must be initialized before being used.
  5. Variables of reference types referred to as objects and store references to the actual data.
1, 3, 5
2, 4
3, 5
2, 3, 4
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
4 comments Page 1 of 1.

AndrewC said:   1 decade ago
Value types do have a default constructor you just can't use it when declaring a new variable. You can use them as below:

class wibble
{
private int i; // Initialised to zero.
}

Jacques Ford said:   1 decade ago
Value types do not have a default constructor that sets default values. If you declare a value type without assigning it a value you get a compile time error. Therefore statement 1 is invalid.

There might be a default constructor which is inherited from its base class but that constructor is empty.

Chandan Gupta said:   1 decade ago
Int? number = null can be assigned as a null but it is not a value type anymore.

Jiten said:   1 decade ago
Values types also can have nullable types. For example int? number = null or int? number =10 .
There is a keyword called Default in C# but I am not very sure that there is a default value for variables.

Post your comments here:

Your comments will be displayed after verification.