What is the correct syntax to declare a nullable integer variable in C#?
A. nullable int num;
B. var? num;
C. int? num;
D. num? int;
Select an option to see the answer and solution.
What is the purpose of the 'unchecked' keyword in C#?
A. Enables overflow checking
B. Terminates the program
C. Compiles the program without errors
D. Disables overflow checking for integral-type arithmetic operations
Select an option to see the answer and solution.
What is the output of the following code: Console.WriteLine($"5 + 5 = {5 + 5}");
A. 5 + 5 = 10
B. 10
C. $"5 + 5 = {5 + 5}"
D. Compilation error
Select an option to see the answer and solution.
What is the correct way to declare and initialize a string variable in C#?
A. string = str;
B. str Hello;
C. str = "Hello";
D. string str = "Hello";
Select an option to see the answer and solution.
Which of the following is NOT a valid C# data type?
A. char
B. void
C. long
D. decimal
Select an option to see the answer and solution.
Type of Conversion in which compiler is unable to convert the data type implicitly is?
A. ushort to long
B. int to uint
C. byte to decimal
D. None of the above
Select an option to see the answer and solution.
Choose ".NET class" name from which data type "UInt" is derived?
A. System.Int16
B. System.UInt32
C. System.UInt64
D. System.UInt16
Select an option to see the answer and solution.
Syntax for declaration and initialization of data variable is?
A. <data type><var_name> = <Value>;
B. <data type><var_name>;
C. <var_name><data type>;
D. <var_name> = <value>;
Select an option to see the answer and solution.
What will be the output of the following C# code?
class Program
{
static void Main(string[] args)
{
int i;
for ( i = 0; i < 5; i++)
{
}
Console. WriteLine(i);
Console. ReadLine();
}
}A. 0, 1, 2, 3, 4, 5
B. 0, 1, 2, 3, 4
C. 5
D. 4
Select an option to see the answer and solution.
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
Select an option to see the answer and solution.
Storage location used by computer memory to store data for usage by an application is?
A. Pointers
B. Constants
C. Variable
D. None of the mentioned
Select an option to see the answer and solution.
For two strings s1 and s2 to be equal, which is the correct way to find if the contents of two strings are equal?
A. if(s1 = s2)
B. int c;
c = s1.CompareTo(s2);
C. if (s1 is s2)
D. if(strcmp(s1, s2))
Select an option to see the answer and solution.
What will be the output of the following C# code?
int a,b;
a = (b = 10) + 5;A. b = 10, a = 5
B. b = 15, a = 5
C. a = 15, b = 10
D. a = 10, b = 10
Select an option to see the answer and solution.
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
A. ii
B. Both i, ii
C. i
D. None of the mentioned
Select an option to see the answer and solution.
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
Select an option to see the answer and solution.
Correct way to define a value 6.28 in a variable 'pi' where value cannot be modified?
A. #define pi 6.28F
B. pi = 6.28F
C. const float pi = 6.28F
D. const float pi
pi = 6.28F
Select an option to see the answer and solution.
Correct way to assign values to variable 'c' when int a=12, float b=3.5, int c;
A. c = a + b;
B. c = a + int(float(b));
C. c = a + convert.ToInt32(b);
D. c = int(a + b);
Select an option to see the answer and solution.
Correct statement about strings are?
A. a string is created on the stack
B. a string is primitive in nature
C. a string created on heap
D. created of string on a stack or on a heap depends on the length of the string
Select an option to see the answer and solution.
What will be the output of the following C# code?
public static void Main(string[] args)
{
int i = 546;
object o = i;
int n =(int) o;
o = 70;
System. Console. WriteLine("The value-type value = {0}", n);
System. Console. WriteLine("The object-type value = {0}", o);
Console. ReadLine();
}A. 546, 0
B. 546, 546
C. 546, 70
D. 70, 546
Select an option to see the answer and solution.
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);
}Select an option to see the answer and solution.