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.

For the following C# code select the relevant solution for conversion of data type.
static void Main(string[] args)
{
int num1 = 20000;
int num2 = 50000;
long total;
total = num1 + num2;
Console.WriteLine(“Total is : ” +total);
Console.ReadLine();
}

For the following C# code select the relevant solution for conversion of data type.
static void Main(string[] args)
{
int num1 = 20000;
int num2 = 50000;
long total;
total = num1 + num2;
Console.WriteLine(“Total is : ” +total);
Console.ReadLine();
}
a) Compiler will generate runtime error
b) Conversion is implicit type, no error generation
c) Specifying data type for conversion externally will solve the problem
d) None of the mentioned

Answer: b
Explanation: Since,conversion of data type is implicit type as ‘int’ is a subset of ‘longtype’ hence no need to explicitly convert data from one type to another.Compiler will automatically do conversion.

Join The Discussion