1)

Which of the conversions are valid for the given set of code?

static void Main(string[] args)
{
int a = 20;
long b = 40;
double c = 1.789;
b = a;
c = a;
a = b;
b = c;
}


A) c = a, b = c

B) a = c, b = a

C) b = a, c = a

D) All of the mentioned

Answer:

Option C

Explanation:

Conversion of data type from ‘int’ to long and double are implicit in nature, as 'long' and 'double' are subset of int. So b = a and c = a are valid. In case of a = b and b = c needs explicit conversion. 

Correct solution

static void Main(string[] args)
{
int a = 20;
long b = 40;
double c = 1.789;
b = a;
c = a;
a = (int)b;
b = (long)c;
}