For the given set of 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();
}
Compiler will generate runtime error
Conversion is implicit type, no error generation
Specifying data type for conversion externally will solve the problem
None of the mentioned
SHOW ANSWERChoose the output for the following set of code.
static void Main(string[] args)
{
char c = 'g';
string s = c.ToString();
string s1 = "I am a human being" + c;
Console.WriteLine(s1);
Console.ReadLine();
}
I am a human bein c
I am a human being
am a human being c
I am a human bein
SHOW ANSWERWhich is the String method used to compare two strings with each other ?
Compare To()
Compare()
Copy()
ConCat()
SHOW ANSWERCorrect output for the given C#.NET code is ?
static void Main(string[] args)
{
string s1 = "Delhi";
string s2;
s2 = s1.Insert (6, "Jaipur");
Console.WriteLine(s2);
}
DelhJaipuri
Delhi Jaipur
Delhi
DelhiJaipur
SHOW ANSWERCorrect output for the C#.NET code given below is :
string s1 = " I AM BEST ";
string s2;
s2 = s1.substring (5, 4);
Console.WriteLine (s2);
AM BEST
I AM BES
BEST
I AM
SHOW ANSWERVerbatim string literal is better used for ?
Convenience and better readability of strings when string text consist of backlash characters
Used to initialize multi line strings
To embed a quotation mark by using double quotation marks inside a verbatim string
SHOW ANSWERPredict the output for the following set of code.
static void Main(string[] args)
{
float a = 16.4f;
int b = 12;
float c;
c = a * ( b + a) / (a - b) ;
Console.WriteLine("result is :" +c);
Console.ReadLine();
}
106
104.789
105.8546
103.45
SHOW ANSWERPredict the solution for the following set of code.
static void Main(string[] args)
{
int a, b, c, x;
a = 90;
b = 15;
c = 3;
x = a - b / 3 + c * 2 - 1;
Console.WriteLine(x);
Console.ReadLine();
}
92
89
90
88
SHOW ANSWERPredict the solution for the following set of code .
static void Main(string[] args)
{
int a, b, c, x;
a = 80;
b = 15;
c = 2;
x = a - b / (3 * c) * ( a + c);
Console.WriteLine(x);
Console.ReadLine();
}
78
-84
80
98
SHOW ANSWERSelect the relevant output for the following set of code:
static void Main(string[] args)
{
int a = 4;
int b = 5;
int c = 6;
int d = 8;
if (((a * b / c) + d) >= ((b * c + d ) / a))
{
Console.WriteLine("Line 1 - a is greater to b");
Console.WriteLine((a * b / c) + d);
}
else
{
Console.WriteLine("Line 1 - a is not greater to b");
Console.WriteLine((b * c + d )/ a);
}
}
“Line 1 – a is greater to b”
“Line 1 – a is not greater to b”
Both are equal
None of the mentioned
SHOW ANSWERSelect the output for the following set of Code:
bool a = true;
bool b = false;
a |= b;
Console.WriteLine(a);
Console.ReadLine();
0
1
True
False
SHOW ANSWERSelect the correct ‘if statement’ to be filled in the given set of code :
static void Main(string[] args)
{
int []num = {50, 65, 56, 88, 43, 52};
int even = 0, odd = 0;
for (int i = 0 ;i < num.Length ;i++)
{
/*___________________________*/
}
Console.WriteLine("Even Numbers:" +even);
Console.WriteLine("Odd Numbers:" +odd);
Console.ReadLine();
}
if ((num % 2) == 0)
{
even += 1;
}
else
{
odd += 1;
}
if((num * i) == 0)
{
even += 1;
}
else
{
odd += 1;
}
if(num[i] % 2 == 0)
{
even += 1;
}
else
{
odd += 1;
}
if(num[i] % 2 = 0)
{
even += 1;
}
else
{
odd += 1;
}
SHOW ANSWERWhat is the output for the following code ?
static void Main(string[] args)
{
int a = 15, b = 10, c = 1;
if (Convert.ToBoolean(a) && (b > c))
{
Console.WriteLine("cquestionbank");
}
else
{
break;
}
}
cquestionbank
It will print nothing
Compile time error
Run time error
SHOW ANSWER