What is the purpose of the "base" keyword in C#?
A. Calls a method in the base class
B. Returns a value
C. Declares a class
D. Throws an exception
Select an option to see the answer and solution.
Which of the following statements about properties in C# is true?
A. Properties cannot be used in inheritance
B. Properties cannot have default values
C. Properties can only have setters
D. Properties encapsulate fields
Select an option to see the answer and solution.
What is the purpose of the "static" keyword in C#?
A. Creates multiple instances
B. Allows inheritance
C. Indicates that a method belongs to the class
D. Declares a class
Select an option to see the answer and solution.
Which of the following statements about constructors in C# is true?
A. Constructors can be inherited
B. Constructors are called when an object is created
C. Constructors can have multiple definitions
D. None of the above
Select an option to see the answer and solution.
What does the "abstract" keyword indicate in C#?
A. Marks a class as sealed
B. Prevents a class from being inherited
C. Marks a class as incomplete
D. Declares a class as static
Select an option to see the answer and solution.
What is the purpose of the "delegate" keyword in C#?
A. Defines a new data type
B. Declares a class
C. Marks a method as virtual
D. Defines a reference type for methods
Select an option to see the answer and solution.
Which of the following is NOT a valid C# data type?
A. float
B. real
C. decimal
D. double
Select an option to see the answer and solution.
What is the default value of a boolean variable in C# if it is not explicitly initialized?
Select an option to see the answer and solution.
What does the "out" keyword allow in C# method parameters?
A. Passing parameters by pointer
B. Passing parameters by value
C. Passing parameters by reference
D. Returning multiple values
Select an option to see the answer and solution.
What is the purpose of the "as" keyword in C#?
A. Imports namespaces
B. Declares a class
C. Performs type casting
D. Calls a method in the base class
Select an option to see the answer and solution.
What does the "var" keyword do in C#?
A. Declares a variable as a constant
B. Specifies an implicitly typed variable
C. Declares a variable as a pointer
D. None of the above
Select an option to see the answer and solution.
Which of the following is NOT a valid type conversion in C#?
A. int to string
B. double to int
C. string to int
D. int to double
Select an option to see the answer and solution.
What does the "out" keyword do in C# method parameters?
A. To pass parameters by reference
B. To pass parameters by value
C. To indicate the return value
D. To indicate an output parameter
Select an option to see the answer and solution.
What does the "async" and "await" keywords do in C#?
A. To perform asynchronous operations
B. To define a new thread
C. To handle exceptions
D. To declare a class
Select an option to see the answer and solution.
What is the purpose of the "is" keyword in C#?
A. Checks if an object is empty
B. Checks if an object is null
C. Compares two objects
D. Checks if an object is of a certain type
Select an option to see the answer and solution.
What does the "as" keyword do in C#?
A. Defines a namespace
B. Creates a new instance
C. Performs type casting
D. Declares a static method
Select an option to see the answer and solution.
What is the purpose of the "typeof" operator in C#?
A. Returns the index of a specified element
B. Returns the address of a specified object
C. Returns the type of a specified object
D. Returns the size of a specified type
Select an option to see the answer and solution.
What does the "break" keyword do in a switch statement in C#?
A. Skips the current iteration
B. Continues to the next iteration
C. Throws an exception
D. Exits the switch statement
Select an option to see the answer and solution.
What will be the output of the following C# code snippet?
public class A
{
public int x;
public int y;
public void display()
{
Console.WriteLine(x + " " + y);
}
}
class Program
{
static void Main(string[] args)
{
A obj1 = new A();
A obj2 = new A();
obj1.x = 1;
obj1.y = 2;
obj2 = obj1;
obj1.display();
obj2.display();
}
}A. 1 2 0 0
B. 1 2 1 2
C. 0 0 0 0
D. Run time exception
Select an option to see the answer and solution.
Which method is called when a thread is blocked from running temporarily?
A. Pulse()
B. PulseAll()
C. Wait()
D. Both Pulse() & Wait()
Select an option to see the answer and solution.