πŸ“Š C#
Q. How many Bytes are stored by β€˜Long’ Data type in C# .net?
  • (A) 8
  • (B) 4
  • (C) 2
  • (D) 1
πŸ’¬ Discuss
βœ… Correct Answer: (A) 8
πŸ“Š C#
Q. Choose β€œ.NET class” name from which data type β€œUInt” is derived?
  • (A) System.Int16
  • (B) System.UInt32
  • (C) System.UInt64
  • (D) System.UInt16
πŸ’¬ Discuss
βœ… Correct Answer: (B) System.UInt32
πŸ“Š C#
Q. 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;
πŸ’¬ Discuss
βœ… Correct Answer: (C) int a = 32; int b = 40;
πŸ“Š C#
Q. What will be the error in the following C# code?
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();
 }
  • (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
πŸ’¬ Discuss
βœ… Correct Answer: (B) Expression assigned to β€˜k’ should be constant in nature
πŸ“Š C#
Q. Arrange the following data type 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
πŸ’¬ Discuss
βœ… Correct Answer: (B) sbyte < short < int < long
πŸ“Š C#
Q. Which data type 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
πŸ’¬ Discuss
βœ… Correct Answer: (A) sbyte
πŸ“Š C#
Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (A) ii
πŸ“Š C#
Q. 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);
πŸ’¬ Discuss
βœ… Correct Answer: (C) c = a + convert.ToInt32(b);
πŸ“Š C#
Q. Default Type of number without decimal is?
  • (A) Long Int
  • (B) Unsigned Long
  • (C) Int
  • (D) Unsigned Int
πŸ’¬ Discuss
βœ… Correct Answer: (C) Int
πŸ“Š C#
Q. What will be the output of the following C# code?
Code:
static void Main(string[] args)
 {
     float a = 10.553f;
     long b = 12L;
     int  c;
     c = Convert.ToInt32(a + b);
     Console.WriteLine(c);
 }
  • (A) 23.453
  • (B) 22
  • (C) 23
  • (D) 22.453
πŸ’¬ Discuss
βœ… Correct Answer: (C) 23