Online Test

I. Which of the following keyword is used for including the namespaces in the program in C#?

  1. imports

  2. using

  3. exports

  4. None of the above.

II. How many Bytes are stored by ‘Long’ Data type in C# .net?

  1. 8
  2. 4
  3. 2
  4. 1

III. Correct Declaration of Values to variables ‘a’ and ‘b’?

  1. int a = 32, b = 40.6;
  2. int a = 42; b = 40;
  3. int a = 32; int b = 40;
  4. int a = b = 42;

IV. 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. ‘k’ should not be declared constant
  2. Expression assigned to ‘k’ should be constant in nature
  3. Expression (m * k) is invalid
  4. ‘m ‘ is declared in invalid format

V. Arrange the following data type in order of increasing magnitude sbyte, short, long, int.

  1. long < short < int < sbyte
  2. sbyte < short < int < long
  3. short < sbyte < int < long
  4. short < int < sbyte < long

VI. Which data type should be more preferred for storing a simple number like 35 to improve execution speed of a program?

  1. sbyte
  2. short
  3. int
  4. long

VII. Correct way to define a value 6.28 in a variable ‘pi’ where value cannot be modified?

  1. #define pi 6.28F
  2. pi = 6.28F
  3. const float pi = 6.28F
  4. const float pi; pi = 6.28F

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


							public static void Main(string[] args)
							{							
								double ZERO = 0;			   
								Console.WriteLine("RESULT OF DIVISION BY ZERO IS :{0}",  (0 / ZERO));			   
								Console.ReadLine();			   
							}
			   
						
  1. 1
  2. exception argument is thrown
  3. NaN
  4. 0

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


							static void Main(string[] args)
							{							
								string s1 = "Delhi";			   
								string s2;			   
								s2 = s1.Insert (6, "Jaipur");			   
								Console.WriteLine(s2);			   
							}			   
			   
						
  1. DelhJaipur
  2. Delhi Jaipur
  3. Delhi
  4. DelhiJaipur

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


							string s1 = " I AM BEST ";
							string s2;				
							s2 = s1.substring (5, 4);				
							Console.WriteLine (s2);				
						
  1. AM BEST
  2. I AM BES
  3. BEST
  4. I AM

XI. Correct statement about strings are?

  1. a string is created on the stack
  2. a string is primitive in nature
  3. a string created on heap
  4. created of string on a stack or on a heap depends on the length of the string

XII. Storage location used by computer memory to store data for usage by an application is?

  1. Pointers
  2. Constants
  3. Variable
  4. none of above

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


							static void Main(string[] args)
							{							
								String name = "Dr.Strange";				
								Console.WriteLine("Good Morning" + name);				
							}							
						
  1. Dr.Strange
  2. Good Morning
  3. Good Morning Dr.Strange
  4. Good Morning name

XIV. Default Type of number without decimal is?

  1. Long Int
  2. Unsigned Long
  3. Int
  4. Unsigned Int

XV. What is the actual type of string in C#?

  1. System.Array
  2. System.char
  3. System.String
  4. Unsigned Int