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 given set of C# code, is conversion possible?
static void Main(string[] args)
{
int a = 76;
char b;
b = (char)a;
Console.WriteLine(b);
Console.ReadLine();
}

For the given set of C# code, is conversion possible?
static void Main(string[] args)
{
int a = 76;
char b;
b = (char)a;
Console.WriteLine(b);
Console.ReadLine();
}
a) Compiler will generate runtime error
b) Conversion is explicit type
c) Compiler will urge for conversion from ‘integer’ to ‘character’ data type
d) None of the mentioned

Answer: b
Explanation: Since, given conversion is of explicit type as one data type is in integer and other is in ‘char’. Compiler is needed to make a clear distinction between both type of data types and hence, explicitly one need to specify data type as compiler is unable to make automatic conversion.

Join The Discussion