Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

What will be the output of the following C# code?

static void Main(string[] args)

int a = 5;

int b = 10;

int c;

Console.WriteLine(c = ++ a + b ++); Console.WriteLine(b);

Console.ReadLine();

*
1 point
a) 11, 10
b) 16, 10
c) 16, 11
d) 15, 11
Arrange the following data type in order of increasing magnitude sbyte, short,
long, int.
*
1 point
a) long < short < int < sbyte
b) sbyte < short < int < long
c) short < sbyte < int < long
d) short < int < sbyte < long
What will be the error in the following C# code?

Static Void Main(String[] args) {


const int m = 100;
int n = 10;
const int k = n / 5 * 100 * n ;
Console.WriteLine(m * k);
Console.ReadLine();
}
*
1 point
a) ‘k’ should not be declared constant
b) Expression assigned to ‘k’ should be constant in nature
c) Expression (m * k) is invalid
d) ‘m ‘ is declared in invalid format
The subset of ‘int’ data type is __________
*
1 point
a) long, ulong, ushort
b) long, ulong, uint
c) long, float, double
d) long, float, ushort
Which of the conversions are valid for the following C# code?

static void Main(string[] args)


{
int a = 22;
long b = 44;
double c = 1.406;
b = a;
c = a;
a = b;
b = c;
}
*
1 point
a) c = a, b = c
b) a = c, b = a
c) b = a, c = a
d) All of the mentioned
Default Type of number without decimal is?
*
1 point
a) Long Int
b) Unsigned Long
c) Int
d) Unsigned Int
Type of Conversion in which compiler is unable to convert the data type implicitly
is?
*
1 point
a) ushort to long
b) int to uint
c) ushort to long
d) byte to decimal
What is the need for ‘Conversion of data type’ in C#?
*
1 point
a) To store a value of one data type into a variable of another data type
b) To get desired data
c) To prevent situations of runtime error during change or conversion of data type
d) None of the mentioned
Which data type should be more preferred for storing a simple number like 35 to
improve execution speed of a program?
*
1 point
a) sbyte
b) short
c) int
d) long
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();
}
*
1 point
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
How many Bytes are stored by ‘Long’ Data type in C# .net?
*
1 point
a) 8
b) 4
c) 2
d) 1
Which Conversion function of ‘Convert.TOInt32()’ and ‘Int32.Parse()’ is efficient?

i) Int32.Parse() is only used for strings and throws argument exception for null
string
ii) Convert.Int32() used for data types and returns directly '0' for null string
*
1 point
a) ii
b) Both i, ii
c) i
d) None of the mentioned
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();
}
*
1 point
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
Correct way to assign values to variable ‘c’ when int a=12, float b=3.5, int c;
*
1 point
a) c = a + b;
b) c = a + int(float(b));
c) c = a + convert.ToInt32(b);
d) c = int(a + b);
‘Implicit Conversion’ follows the order of conversion as per compatibility of data
type as:
*
1 point
a) float < char < int
b) char < int < float
c) int < char < float
d) float < int < char
What will be the output of the following C# code?

static void Main(string[] args)


{
float sum; int i; sum = 0.0F;
for (i = 1; i <= 10; i++)
{
sum = sum + 1 /(float)i;
}
Console.WriteLine("sum =" +sum);
Console.ReadLine();
}
*
1 point
a) 2.000
b) 2.910
c) 2.928
d) 3.000
What will be the output of the following C# code?

static void Main(string[] args) {


float a = 10.553f;
long b = 12L;
int c;
c = Convert.ToInt32(a + b);
Console.WriteLine(c);
}
*
1 point
a) 23.453
b) 22
c) 23
d) 22.453
Roll No
*
39
Correct Declaration of Values to variables ‘a’ and ‘b’?
*
1 point
a) int a = 32, b = 40.6;
b) int a = 42; b = 40;
c) int a = 32; int b = 40;
d) int a = b = 42;
Disadvantages of Explicit Conversion are?
*
1 point
a) Makes program memory heavier
b) Results in loss of data
c) Potentially Unsafe
d) None of the mentioned
2. Choose “.NET class” name from which data type “UInt” is derived?
*
1 point
a) System.Int16
b) System.UInt32
c) System.UInt64
d) System.UInt16

You might also like