- Home
- Programming
- C Sharp Programming
26.
If i is an int and l is a long, which of the following statements is true?
- A.i = (int)l is a narrowing conversion.
- B.l = (long)i is a narrowing conversion.
- C.l = (long)i could cause an integer overflow.
- D.The correct way to copy i’s value into l is l = long.Parse(i).
- Answer & Explanation
- Report
Answer : [A]
Explanation :
Explanation :
27.
Which of the following statements is true for widening conversions?
- A.Any value in the source type can fit into the destination type.
- B.The conversion will not result in loss of magnitude but may result is some loss of precision.
- C.An explicit cast is optional.
- D.All of the above.
- Answer & Explanation
- Report
Answer : [D]
Explanation :
Explanation :
28.
Which of the following statements is true for narrowing conversions?
- A.The conversion will not result in loss of magnitude but may result is some loss of precision.
- B.The source and destination types must be compatible.
- C.An explicit cast is optional.
- D.A cast can convert a string into an int if the string holds numeric text.
- Answer & Explanation
- Report
Answer : [B]
Explanation :
Explanation :
29.
Assuming total is a decimal variable holding the value 1234.56, which of the following
statements displays total with the currency format $1,234.56?
- A.Console.WriteLine(total.ToString());
- B.Console.WriteLine(total.ToCurrencyString());
- C.Console.WriteLine(total.ToString("c"));
- D.Console.WriteLine(Format("{0:C}", total);
- Answer & Explanation
- Report
Answer : [C]
Explanation :
Explanation :
30.
Which of the following statements generates a string containing the text "Veni, vidi,vici"?
- A.String.Format("{0}, {1}, {2}", Veni, vidi, vici)
- B.String.Format("{1}, {2}, {3}", "Veni", "vidi", "vici")
- C.String.Format("{2}, {0}, {3}", "vidi", "Venti", "Veni", "vici")
- D.String.Format("{Veni, vidi, vici}")
- Answer & Explanation
- Report
Answer : [C]
Explanation :
Explanation :