Home

What is the correct answer?

4

Correct Set of Code for given data ‘a’ and ‘b’ to print output for ‘c’ as 74

A.

int a = 12;
float b = 6.2f;
int c;
c = a / b + a * b;
Console.WriteLine(c);

B.

int a = 12;
float b = 6.2f;
int c;
c = a / convert.ToInt32(b) + a * b;
Console.WriteLine(c);

C.

int a = 12;
float b = 6.2f;
int c;
c = a / convert.ToInt32(b) + a * convert.ToInt32(b);
Console.WriteLine(c);

D.

int a = 12;
float b = 6.2f;
int c;
c = convert.ToInt32(a / b + a * b);
Console.WriteLine(c);

Correct Answer :

C.

int a = 12;
float b = 6.2f;
int c;
c = a / convert.ToInt32(b) + a * convert.ToInt32(b);
Console.WriteLine(c);


Usage of typecasting operation. Seperately check each expression taking typecast operations in concern.
Output : 74.

Related Questions

What is the correct answer?

4

Correct Set of Code for given data ‘a’ and ‘b’ to print output for ‘c’ as 74 ?

A.

int a = 12;
float b = 6.2f;
int c;
c = a / b + a * b;
Console.WriteLine(c);

B.

int a = 12;
float b = 6.2f;
int c;
c = a / convert.ToInt32(b) + a * b;
Console.WriteLine(c);

C.

int a = 12;
float b = 6.2f;
int c;
c = a / convert.ToInt32(b) + a * convert.ToInt32(b);
Console.WriteLine(c);

D.

int a = 12;
float b = 6.2f;
int c;
c = convert.ToInt32(a / b + a * b);
Console.WriteLine(c);

What is the correct answer?

4

Select error in the given program :
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();
}

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

What is the correct answer?

4

Choose “.NET class” name from which datatype “UInt” is derived ?

A. System.Int16

B. System.UInt32

C. System.UInt64

D. System.UInt16

What is the correct answer?

4

Correct Set of Code for given data ‘a’ and ‘b’ to print output for ‘c’ as 74

A.

int a = 12;
float b = 6.2f;
int c;
c = a / b + a * b;
Console.WriteLine(c);

B.

int a = 12;
float b = 6.2f;
int c;
c = a / convert.ToInt32(b) + a * b;
Console.WriteLine(c);

C.

int a = 12;
float b = 6.2f;
int c;
c = a / convert.ToInt32(b) + a * convert.ToInt32(b);
Console.WriteLine(c);

D.

int a = 12;
float b = 6.2f;
int c;
c = convert.ToInt32(a / b + a * b);
Console.WriteLine(c);

What is the correct answer?

4

Correct Declaration of Values to variables a and b?

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;

What is the correct answer?

4

How many Bytes are stored by Long Datatype in C# .net?

A. 8

B. 4

C. 2

D. 1

What is the correct answer?

4

Which datatype should be more preferred for storing a simple number like 35 to improve execution speed of a program?

A. sbyte

B. short

C. int

D. long

What is the correct answer?

4

Which Conversion function of Convert.TOInt32() and Int32.Parse() is efficient?
1) Int32.Parse() is only used for strings and throws argument exception for null string
2) Convert.Int32() used for datatypes and returns directly 0 for null string

A. 2

B. Both 1,2

C. 1

D. None of the mentioned

What is the correct answer?

4

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) ;

What is the correct answer?

4

Arrange the following datatype in order of increasing magnitude sbyte, short, long, int.

A. long < short < int < sbyte

B. sbyte < short < int < long

C. short < sbyte < int < long

D. short < int < sbyte < long