C Sharp .Net Quiz

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

A local variable

  1. Can be used anywhere in the program

  2. Is declared within a method

  3. Must accept a class

  4. Represent a class object


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) Can be used anywhere in the program - This option is incorrect because local variables have limited scope and are only accessible within the block of code in which they are declared.

Option B) Is declared within a method - This option is correct because local variables are declared within a method or a block of code in a program. They are only accessible within that specific method or block.

Option C) Must accept a class - This option is incorrect because local variables are not required to accept a class. They can be of any data type, such as integers, strings, or booleans.

Option D) Represent a class object - This option is incorrect because local variables do not necessarily represent class objects. They can hold any value or data type, not just class objects.

The correct answer is B) Is declared within a method. This option is correct because local variables are declared within a method or a block of code in a program and are only accessible within that specific method or block.

An instance variable

  1. is an object of a class

  2. represents an attribute of an object

  3. is a method of a class

  4. a and c


Correct Option: B

Private Button print = new button();

  1. creates a button control

  2. initializes a button control

  3. instantiates button control

  4. a and b

  5. a and c


Correct Option: E

AI Explanation

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

Option A) creates a button control - This option is incorrect because the code provided does not create a button control. It only declares a variable named "print" of type "Button" and assigns it a new instance of the "Button" class.

Option B) initializes a button control - This option is incorrect because the code provided does not initialize a button control. It only declares a variable named "print" and assigns it a new instance of the "Button" class.

Option C) instantiates button control - This option is correct because the code provided instantiates a button control. It creates a new instance of the "Button" class and assigns it to the variable "print".

Option D) a and b - This option is incorrect because the code provided does not create or initialize a button control. It only declares a variable named "print" and assigns it a new instance of the "Button" class.

Option E) a and c - This option is correct because the code provided both creates and instantiates a button control. It declares a variable named "print" of type "Button" and assigns it a new instance of the "Button" class.

The correct answer is E. This option is correct because the code provided both creates and instantiates a button control.

An instance method

  1. Represents the behavior of an object

  2. Represents the attribute of an object

  3. Represents another class

  4. a and b


Correct Option: A

A Constructor

  1. is used to create objects

  2. must have the same name as the class it is declared within

  3. maybe overloaded

  4. b and c

  5. all of the above


Correct Option: E

class Test: Form { }

  1. Creates the class Test : Form

  2. Creates the class Test that inherits the class Form

  3. Creates the class form that inherits the class Test

  4. a and b


Correct Option: B

A variable declared inside a method is called a________variable

  1. Static

  2. Private

  3. Local

  4. Serial

  5. b and d


Correct Option: C

Defining two methods with the same name but with different parameters is called.

  1. Loading

  2. Overloading

  3. Multiplexing

  4. Duplexing


Correct Option: B

AI Explanation

To answer this question, you need to understand the concept of method overloading.

Method overloading is the ability to define multiple methods with the same name but with different parameters. This allows you to perform different operations based on the arguments passed to the method.

Let's go through each option to understand why it is correct or incorrect:

Option A) Loading - This option is incorrect. "Loading" is not the term used to describe defining two methods with the same name but with different parameters.

Option B) Overloading - This option is correct. Method overloading is the term used to describe defining two methods with the same name but with different parameters.

Option C) Multiplexing - This option is incorrect. "Multiplexing" refers to combining multiple signals into a single channel.

Option D) Duplexing - This option is incorrect. "Duplexing" refers to the ability of a communication system to transmit and receive data simultaneously.

The correct answer is B) Overloading. This option is correct because it accurately describes the concept of defining two methods with the same name but with different parameters.

Find any errors in the following BankAccount constructor: public int BankAccount() { balance = 0; }

  1. Name

  2. Formal parameters

  3. Return type

  4. No errors


Correct Option: C

AI Explanation

To answer this question, you need to understand the concept of constructors in Java.

Let's go through each option to understand why it is correct or incorrect:

Option A) Name - This option is incorrect because the name of the constructor is not an error. In Java, the name of the constructor must match the name of the class. However, since the class name is not provided in the question, we cannot determine if the name is correct or not.

Option B) Formal parameters - This option is incorrect because the absence of formal parameters in the constructor is not an error. Constructors can have formal parameters, but they can also be parameterless.

Option C) Return type - This option is correct because constructors do not have a return type. In the given code, the constructor is declared with the return type "int", which is incorrect. Constructors should not have any return type specified.

Option D) No errors - This option is incorrect because there is an error in the given code. The error is in the return type of the constructor. Constructors should not have a return type specified.

The correct answer is C) Return type. This option is correct because constructors do not have a return type specified.

In the body of a method, C# uses the variable named_____to refer to the current object whose method is being invoked.

  1. call

  2. this

  3. do

  4. that


Correct Option: B

Classes declared with the sealed keyword cannot be base class.

  1. True

  2. False


Correct Option: A

Exception objects are derived from the class.

  1. Try

  2. Catch

  3. Exception

  4. Event

  5. System


Correct Option: C
  1. may contain instance variables

  2. may contain constructors

  3. may extend another class

  4. a and b

  5. all of the above


Correct Option: E

A____block enclose the code that could throw an exception.

  1. Try

  2. Catch

  3. Exception

  4. Error

  5. a and b


Correct Option: A
- Hide questions