Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

The following C# codes are?
1. Myclass class;
Myclass class2 = null;
2. int i;
int j = 0;

The following C# codes are?
1. Myclass class;
Myclass class2 = null;
2. int i;
int j = 0;
a) True for (1);False for (2)
b) True for (2);False for (1)
c) Both (1) and (2) are equivalents
d) Both (1) and (2) are not equivalents

Answer: c
Explanation: When we create a type in ‘C#’, It automatically gets filled with padded zeros. For the case of class (reference types) this equates to a null pointer. Hence, for code 1) Both variable values are equivalent to each other.Similarly, for code 2) i.e for value type (including int/float/double etc.), the type is passed with zeros. Hence, they are equivalent.

Join The Discussion