Csharp Multiple Choice
Csharp Multiple Choice
A) .NET Framework
B) Java Virtual Machine
C) Both A. and B.
D) None of the above
9. Which symbols are used to mark the beginning and end of a code block?
A) Square brackets []
B) Curly braces {}
C) Round brackets ()
D) Double-quotes “”
12. Which is the correct order for implicit type conversion to convert a smaller to a larger type
in C#?
A) char -> int -> long -> float -> double
B) bool -> char -> int -> long -> float -> double
C) char -> int -> float -> long -> double
D) bool -> char -> int -> long -> double -> float
13. Which is the correct order for explicit type conversion to convert a larger to a smaller type
in C#?
A) double -> float -> long -> int -> char -> bool
B) double -> float -> long -> int -> char
C) float -> double -> long -> int -> char
D) float -> double -> long -> int -> char -> bool
14. Which is the correct C# statement to convert a float value to int explicitly?
A) int_variable = (int) float_variable;
B) int_variable = float_variable;
C) int-variable = (int) (float_variable);
D) int_variable = int* float_variable);
15. What is the process of converting a value type to the object type?
A) Explicit
B) Unboxing
C) Boxing
D) Compilation
17. What will be the output of the following C# code, if the input is 379?
using System;
namespace MyApplication {
class Program {
static void Main(string[] args) {
Console.WriteLine("Enter a number:");
int num = Console.ReadLine();
Console.WriteLine("Given number is: " + num);
}
}
}
A) Given number is:379
B) Given number is: 379
C) Given number is: "379"
D) Error
18. What is the difference between Console.Write() and Console.WriteLine() methods in C#?
A) Write() writes a single character while Console.WriteLine() writes a complete
line
B) Write() writes the data on the console without printing a newline while
Console.WriteLine() writes the data on the console along with printing a
newline
C) ToFloat(Console.ReadLine());
D) Write() writes the string on the console while Console.WriteLine() writes the
string as well as values of the variables on the console
E) Both can be used for the same purpose
30. Which String class operator is used to determine whether two specified strings have
different values?
A) !=
B) !
C) ~
D) ~=
35. Which array property is used to get the total number of elements in C#?
A) Len
B) Length
C) Elements
D) MaxLen
38. Which of the correct syntax to declare an array with 2 rows and 3 columns in C#?
A) int arr[2][3] = new int[2][3];
B) int arr[2,3] = new int[2,3];
C) int[,] arr = new int[2,3];
D) int [,]arr = new [2,3]int;
39. Which is the correct way to declare an object of the class in C#?
A) Class_Name Object_Name = new Class_Name();
B) Class_Name Object_Name;
C) new Object_Name as Class_Name();
D) Both A and B
45. Which C# concept has the capability of an object to take number of different forms and
hence display behaviour as accordingly?
A) Polymorphism
B) Encapsulation
C) Abstraction
D) None of the above
46. In C#, the objects created using new operator are stored in ___. (***The heap is used for
storing objects in memory. The stack memory is responsible for keeping track of the
running memory needed in your application. (local variable)***)
A) Cache Memory
B) Stack Memory
C) Heap Memory
D) None of the above
49. Which of the correct syntax to declare an array with 2 rows and 3 columns in C#?
A) int arr[2][3] = new int[2][3];
B) int arr[2,3] = new int[2,3];
C) int[,] arr = new int[2,3];
D) int [,]arr = new [2,3]int;
51. How many catch blocks can be used with a single try block in C#?
A) One
B) Two
C) Many
D) None of the above