A. int x;
B. x int;
C. int: x;
D. int = x;
Answer: A. int x;
2. Which keyword is
used to define a class in C?
A. class
B. define
C. struct
D. function
Answer: A. class
3. How do you create
a new object in C?
A. new ClassName();
B. ClassName obj = new ClassName();
C. ClassName obj = create ClassName();
D. new ClassName obj;
Answer: B. ClassName obj = new ClassName();
4. Which of the
following is the entry point of a C console application?
A. Main()
B. Start()
C. Begin()
D. Init()
Answer: A. Main()
5. How do you write a
singleline comment in C?
A. // comment
B. / *comment* /
C. <! comment >
D. comment
Answer: A. // comment
6. Which of the
following is not a value type in C?
A. int
B. float
C. bool
D. string
Answer: D. string
7. How do you handle
exceptions in C?
A. try...catch
B. try...except
C. try...finally
D. try...handle
Answer: A. try...catch
8. Which method is
used to get the length of a string in C?
A. str.size()
B. str.length()
C. str.Length
D. str.getSize()
Answer: C. str.Length
9. Which keyword is
used to inherit a class in C?
A. inherits
B. extends
C. implements
D. :
Answer: D. :
10. How do you define
a constant in C?
A. const int x = 10;
B. define int x = 10;
C. static int x = 10;
D. final int x = 10;
Answer: A. const int x = 10;
11. Which of the
following access specifiers is the most restrictive?
A. public
B. protected
C. private
D. internal
Answer: C. private
12. What is the
default value of an uninitialized int variable in C?
A. null
B. 0
C. 1
D. undefined
Answer: B. 0
13. How do you
declare an array in C?
A. int[] arr;
B. int arr[];
C. array int arr;
D. int arr{};
Answer: A. int[] arr;
14. Which keyword is
used to define an interface in C?
A. class
B. interface
C. implements
D. abstract
Answer: B. interface
15. What does the static
keyword mean in C?
A. The method or variable belongs to the class
itself.
B. The method or variable cannot be changed.
C. The method or variable is inherited.
D. The method or variable is accessible only
within its own class.
Answer: A. The method or variable belongs to
the class itself.
16. How do you
convert a string to an integer in C?
A. int.Parse(string)
B. Convert.ToInt32(string)
C. int.TryParse(string, out int result)
D. All of the above
Answer: D. All of the above
17. Which method is
used to add an element to a list in C?
A. list.append()
B. list.add()
C. list.insert()
D. list.Add()
Answer: D. list.Add()
18. How do you check
if two strings are equal in C?
A. str1 == str2
B. str1.Equals(str2)
C. string.Compare(str1, str2)
D. All of the above
Answer: D. All of the above
19. Which of the
following is not a loop structure in C?
A. for
B. foreach
C. while
D. repeat
Answer: D. repeat
20. How do you define
a property in C?
A. public int MyProperty { get; set; }
B. public int MyProperty { get; get; }
C. public int MyProperty { set; set; }
D. public int MyProperty { set; get; }
Answer: A. public int MyProperty { get; set; }
A. static
B. sealed
C. abstract
D. final
Answer: B. sealed
22. How do you
declare a delegate in C?
A. public delegate int MyDelegate();
B. delegate int MyDelegate();
C. public delegate int MyDelegate;
D. delegate int MyDelegate;
Answer: B. delegate int MyDelegate();
23. What is the
purpose of the using statement in C?
A. To include namespaces.
B. To handle resources.
C. To manage memory.
D. To declare variables.
Answer: B. To handle resources.
24. Which of the
following is not a valid C keyword?
A. volatile
B. override
C. implicit
D. inherits
Answer: D. inherits
25. How do you create
an anonymous method in C?
A. delegate { // code }
B. new delegate { // code }
C. new delegate { }
D. delegate (int x) { // code }
Answer: A. delegate { // code }
26. What is the
output of the following code?
int x = 10;
x++;
Console.WriteLine(x);
A. 9
B. 10
C. 11
D. 12
Answer: C. 11
27. How do you handle
multiple exceptions in C?
A. try...catch...catch
B. try...catch...finally
C. try...catch...multiple
D. try...catch...all
Answer: A. try...catch...catch
28. What is the
purpose of the finally block in C?
A. To execute code regardless of an exception.
B. To handle exceptions.
C. To declare final variables.
D. To finalize an object.
Answer: A. To execute code regardless of an
exception.
29. Which keyword is
used to return a value from a method in C?
A. exit
B. return
C. break
D. stop
Answer: B. return
30. How do you create
a readonly property in C?
A. public int MyProperty { get; }
B. public int MyProperty { get; private set; }
C. public int MyProperty { private get; set; }
D. public int MyProperty { get; protected set; }
Answer: A. public int MyProperty { get; }
31. Which of the
following is a reference type in C?
A. int
B. bool
C. char
D. string
Answer: D. string
32. How do you
declare an enumeration in C?
A. enum Colors { Red, Green, Blue }
B. enumeration Colors { Red, Green, Blue }
C. enum Colors: int { Red, Green, Blue }
D. enumeration Colors: int { Red, Green, Blue }
Answer: A. enum Colors { Red, Green, Blue }
33. What is the
purpose of the is keyword in C?
A. To check the type of an object.
B. To compare two values.
C. To declare an interface.
D. To instantiate an object.
Answer: A. To check the type of an object.
34. How do you
implement an interface in C?
A. public class MyClass : IMyInterface { }
B. public class MyClass implements IMyInterface { }
C. public class MyClass inherit IMyInterface { }
D. public class MyClass include IMyInterface { }
Answer: A. public class MyClass : IMyInterface { }
35. Which of the
following is used to define a generic class in C?
A. class MyClass<T> { }
B. class MyClass<T extends Type> { }
C. class MyClass<T implements Type> { }
D. class MyClass<T: Type> { }
Answer: A. class MyClass<T> { }
A. Thread t = new Thread(ThreadStart);
B. Thread t = create Thread(ThreadStart);
C. Thread t = new Thread(Thread);
D. Thread t = create Thread(Thread);
Answer: A. Thread t = new Thread(ThreadStart);
37. What is the output of the following code?
int[] arr = {1, 2,
3};
Console.WriteLine(arr.Length);
A. 2
B. 3
C. 4
D. 5
Answer: B. 3
38. Which of the
following is not a valid operator in C?
A. +
B. -
C. *
D. &&
Answer: D. &&
39. How do you create
a lambda expression in C?
A. (x, y) => x + y
B. lambda (x, y) { return x + y; }
C. fun (x, y) => x + y
D. lambda x, y: x + y
Answer: A. (x, y) => x + y
40. Which of the
following is not a valid data type in C?
A. int
B. float
C. double
D. real
Answer: D. real
41. How do you write
a multiline comment in C?
A. / comment /
B. <! comment >
C. comment
D. // comment //
Answer: A. / comment /
42. What is the
purpose of the ref keyword in C?
A. To pass a variable by reference.
B. To pass a variable by value.
C. To reference a variable.
D. To refer to an object.
Answer: A. To pass a variable by reference.
43. Which of the
following is not an access modifier in C?
A. public
B. protected
C. internal
D. friendly
Answer: D. friendly
44. How do you
declare an abstract class in C?
A. public abstract class MyClass { }
B. public class abstract MyClass { }
C. public MyClass abstract { }
D. abstract public class MyClass { }
Answer: A. public abstract class MyClass { }
45. What is the
output of the following code?
csharp
bool isTrue = true;
Console.WriteLine(isTrue ? "Yes" : "No");
A. Yes
B. No
C. True
D. False
Answer: A. Yes
46. How do you
implement a method in an interface in C?
A. public void MyMethod() { }
B. void MyMethod();
C. void MyMethod { }
D. method void MyMethod { }
Answer: B. void MyMethod();
47. What does the this
keyword represent in C?
A. The current instance of the class.
B. A static reference to the class.
C. The parent class.
D. The base class.
Answer: A. The current instance of the class.
48. How do you
declare a nullable type in C?
A. int?
B. nullable int
C. int!
D. int~
Answer: A. int?
49. Which of the
following is used to compare the values of two strings in C?
A. ==
B. Equals()
C. CompareTo()
D. All of the above
Answer: D. All of the above
50. How do you
declare a destructor in C?
A. ~MyClass() { }
B. destructor MyClass() { }
C. MyClass::~() { }
D. ~MyClass { }
Answer: A. ~MyClass() { }
0 Comments:
Post a Comment