0

Basic C# .net Quiz

Description: Basic C# .net Quiz
Number of Questions: 15
Created by:
Tags: .net c-sharp
Attempted 0/15 Correct 0 Score 0

String mystring; Creates a(n)

  1. Class

  2. Constructor

  3. Object

  4. a and b


Correct Option: C

AI Explanation

To answer this question, we need to understand the concepts of classes, constructors, and objects.

In programming, a class is a blueprint for creating objects. It defines the properties and behaviors that an object of that class will have.

A constructor, on the other hand, is a special method within a class that is used to initialize objects of that class. It is typically called when an object is created.

An object, in simple terms, is an instance of a class. It is created using the blueprint defined by the class and can have its own unique set of data and behavior.

Now, let's go through each option to understand why it is correct or incorrect:

Option A) Class - This option is incorrect because the statement "String mystring;" does not define a class. It only declares a variable named "mystring" of type String.

Option B) Constructor - This option is incorrect because the statement "String mystring;" does not define a constructor. It only declares a variable named "mystring" of type String.

Option C) Object - This option is correct because the statement "String mystring;" declares a variable named "mystring" of type String. This variable can be assigned an object of the String class, making it an object.

Option D) a and b - This option is incorrect because the statement "String mystring;" does not define a class or a constructor. It only declares a variable named "mystring" of type String.

Therefore, the correct answer is Option C) Object. The statement "String mystring;" creates an object of type String.

An Event is

  1. The result of a users action

  2. result of a party

  3. code to force users action


Correct Option: A

A delegate defines

  1. a Wahsington representative

  2. a class that encapsulates methods

  3. a means of passing arrays into methods

  4. a substitue for an inherited method


Correct Option: B

Is it possible to pass methods as arguments for other methods without modification.

  1. True

  2. False


Correct Option: A

All interfaces must contain IDrivable

  1. True

  2. False


Correct Option: B

AI Explanation

To answer this question, we need to understand the concept of interfaces in programming.

An interface is a collection of abstract methods that can be implemented by any class. It defines a contract that specifies what methods a class must implement if it wants to be considered as implementing that particular interface.

Now, coming back to the question, the statement "All interfaces must contain IDrivable" is false. This is because an interface can define any methods, and it is not necessary for an interface to contain the method "IDrivable".

Therefore, the correct answer is B) False.

What is the proper header for a class that intends to use an interface.

  1. class MyClass IFace

  2. class MyClass ; IFace

  3. class MyClass : IFace

  4. class MyCalss {IFace}

  5. class MyCalss(IFace)


Correct Option: C
  1. inherit the properties of the interface

  2. contain the same methods as the interface

  3. create an interface objects

  4. a and b

  5. all of the above


Correct Option: E

Every class directly or indirectly extends the______class.

  1. System

  2. Object

  3. Drawing

  4. Console


Correct Option: B

AI Explanation

To answer this question, you need to have a basic understanding of object-oriented programming.

Option A) System - This option is incorrect because the System class is not the superclass of all classes in object-oriented programming.

Option B) Object - This option is correct because the Object class is the superclass of all classes in object-oriented programming. In Java, for example, every class directly or indirectly extends the Object class.

Option C) Drawing - This option is incorrect because the Drawing class is not a commonly used superclass in object-oriented programming.

Option D) Console - This option is incorrect because the Console class is not the superclass of all classes in object-oriented programming.

The correct answer is Option B) Object. This option is correct because the Object class serves as the superclass of all classes in object-oriented programming.

The concept of composition specifies that you can.

  1. Compose good code with C#

  2. Compose C# projects with different objects

  3. Reduce errors by remaining composed during programming

  4. all of the above


Correct Option: B

Polymorphism occurs when the methods of the child class.

  1. Override the parent class methods but maintain the implementation

  2. Maintain the same return type and arguments as the parent class, but implement it differently

  3. Have different return types and arguments than the parent class

  4. Are Virtual


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Override the parent class methods but maintain the implementation - This option is incorrect. Polymorphism does involve overriding methods from the parent class, but it allows for changing the implementation of these methods, not maintaining the same implementation.

Option B) Maintain the same return type and arguments as the parent class but implement it differently - This option is correct. Polymorphism occurs when a child class provides a different implementation of a method that is already defined in the parent class. The method in the child class must have the same return type and arguments as the method in the parent class.

Option C) Have different return types and arguments than the parent class - This option is incorrect. Polymorphism requires the child class method to have the same return type and arguments as the parent class method. Having different return types and arguments would result in method overloading, not polymorphism.

Option D) Are Virtual - This option is incorrect. Virtual methods in object-oriented programming languages allow for method overriding, but they are not a requirement for polymorphism. Polymorphism can occur with or without virtual methods.

The correct answer is B. This option is correct because it accurately describes polymorphism, where the child class methods maintain the same return type and arguments as the parent class methods but implement them differently.

The way of returning a thread from s suspended state is:

  1. Pulse

  2. PulseAll

  3. Interrupt

  4. Resume

  5. ReStart


Correct Option: D

In order to lock/unlock an object use the.

  1. Lock and Unlock methods

  2. Enter and Exit methods

  3. Close and Open methods

  4. Close and Allow methods


Correct Option: B

Class String and the Char structure found in the:

  1. System.Strings namespace

  2. System.Text namespace

  3. System.Chars namespace

  4. System namespace


Correct Option: D

A String literal is a:

  1. only contains one character

  2. contains numbers rather than letters

  3. sequence of characters in double quotation marks

  4. contains exactly its variable name and nothing else


Correct Option: C

To create a string literal exclude escape sequence, use:

  1. !string

  2. @string

  3. #string

  4. $string


Correct Option: B

AI Explanation

To answer this question, we need to understand how to create a string literal in programming.

A string literal is a sequence of characters enclosed in quotation marks. In some programming languages, certain characters within a string may have special meaning and need to be escaped using escape sequences.

In the given question, we are looking for the option that allows us to create a string literal without using any escape sequences.

Option A) !string - This option is incorrect because it does not follow the syntax for creating a string literal.

Option B) @string - This option is correct because in some programming languages, such as C#, the '@' symbol before a string literal allows us to create a verbatim string literal. In a verbatim string literal, escape sequences are not processed, and the string is interpreted exactly as it is written.

Option C) #string - This option is incorrect because it does not follow the syntax for creating a string literal.

Option D) $string - This option is incorrect because it does not follow the syntax for creating a string literal.

The correct answer is B) @string. This option is correct because it allows us to create a string literal without using any escape sequences.

- Hide questions