Alien head

C# Programming

Description: C Sharp
Number of Questions: 16
Created by:
Tags: C Sharp Programming
Attempted 0/16 Correct 0 Score 0

Which of the following directive is used to undefine any symbol used in the C# program?

  1. #define

  2. #error

  3. #warning

  4. #undef

  5. #if


Correct Option: D
Explanation:

This directive is used to undefine any symbol used in the C# program which causes no effect of the symbol defined using #define directive.

The 'bool data type' in C# belongs to ________________ type.

  1. struct

  2. enumeration

  3. simple

  4. class

  5. character


Correct Option: C
Explanation:

The bool type in C# belongs to simple type.

Which of the following is the correct method of using the 'if statement' in c#?

  1. if expression
    text if true

  2. expression if#
    text if true

  3. #if expression

    text-if-true

  4. #endif

  5. #elif


Correct Option: C
Explanation:

This is the correct method of using if statement as it requires #if directive to be used.

Which of the following statement is used in C# to specify a block of code that can be expanded or collapse when using outlining feature of the Visual Studio Code Editor?

  1. #endregion

  2. #region

  3. #line

  4. #undef

  5. #define


Correct Option: B
Explanation:

This statement is used in C# to specify a block of code that can be expanded or collapse when using outlining feature of the Visual Studio Code Editor.

Which of the following member modifier in C# indicates that a method or accessor does not contain an implementation?

  1. const

  2. abstract

  3. event

  4. extern

  5. override


Correct Option: B
Explanation:

This member modifier in C# indicates that a method or accessor does not contain an implementation.

Which of the following access modifier is used to access members in the class and all the derived classes of the base class, but no access from any outside class, which is not the derived class of the base class?

  1. public

  2. private

  3. protected

  4. internal

  5. static


Correct Option: C
Explanation:

This access modifier is used to access members in the class and all the derived classes of the base class.

Which of the following member modifier in C# indicates that the method or accessor can be overridden by inheriting classes?

  1. static

  2. override

  3. virtual

  4. readonly

  5. const


Correct Option: C
Explanation:

This member modifier in C# indicates that the method or accessor can be overridden by inheriting classes.

What is the meaning of the following statement written in C#?
class A : B

  1. Class A is derived in class B

  2. Method of class A is implemented in class B

  3. Class B is derived in class A

  4. Class A and class B are same class

  5. Class B cannot be derived in class A


Correct Option: C
Explanation:

This is the correct option as colon operator is used in C# to inherit any class in an existing class.

Which of the following type is used in C# when a value is boxed?

  1. Object type

  2. Class type

  3. Interfaces

  4. Delegates

  5. String type


Correct Option: A
Explanation:

This type is used in C# when a value is boxed,  which means a value refers to implicitly converting any value type to the type object.

Which of the following exception is raised in C# when a method throws an exception in case an argument is null where not allowed?

  1. SystemException

  2. ArgumentNullException

  3. IndexOutOfRangeException

  4. InteropException

  5. ComException


Correct Option: B
Explanation:

This exception is raised in C# when a method throws an exception in case an argument is null.

Which of the following directive is used in C# to define a symbol, which can be used with the #if directive to evaluate any expression?

  1. #undef

  2. #warning

  3. #define

  4. #elif

  5. #else


Correct Option: C
Explanation:

This directive is used in C# to define a symbol,  which can be used with the #if directive to evaluate any expression.

Which of the following data type in C# is the type-safe and secure version of function pointers?

  1. Interfaces

  2. Class

  3. Object

  4. Delegates

  5. String


Correct Option: D
Explanation:

This data type in C# is the type-safe and secure version of function pointers.

Which of the following statement is used in C# to output any value or expression?

  1. System.out.println(xyz);

  2. cout<

  3. Console.WriteLine(xyz)

  4. dbms_output.put_line(xyz)

  5. printf(%s,a);


Correct Option: C
Explanation:

This is the correct output statement used in C# to output any value.

Which of the following is the best method of accessing a method of the base class in C#?

  1. Declare the method outside the base class only.

  2. Declare the method in the derived class only.

  3. Declare the method in both base class and derived class.

  4. Declare the method in the base class with the keyword 'Hide'.

  5. Delete the method declared in base and derived class.


Correct Option: C
Explanation:

This is the correct option as the method is declared in both base and derived class by default the derived version of the method is only accessible but to access the base class method the following changes has to be done in the program.
DerivedClass test = new DerivedClass();
 ((BaseClass)test).TestMethod();
  The above code will only access the base class method of a class.

Which of the following Exception class is used when the call to the method is invalid for the objects current state?

  1. SystemException

  2. InvaildOperationException

  3. ArgumentException

  4. SEHException

  5. ComException


Correct Option: B
Explanation:

This Exception class is used when the call to the method is invalid for the objects current state.

Which of the following Exception class is used when the call to the method is invalid for the objects current state?

  1. SystemException

  2. InvaildOperationException

  3. ArgumentException

  4. SEHException

  5. ComException


Correct Option: B
Explanation:

This Exception class is used when the call to the method is invalid for the objects current state.

+ View questions