Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

101.

What Are The Different Ways A Method Can Be Overloaded?

Answer»

DIFFERENT parameter DATA types, different NUMBER of PARAMETERS, different order of parameters.

Different parameter data types, different number of parameters, different order of parameters.

102.

Can You Declare An Override Method To Be Static If The Original Method Is Not Static?

Answer»

No. The signature of the virtual METHOD MUST remain the same. (NOTE: Only the KEYWORD virtual is changed to keyword override)

No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)

103.

How Is Method Overriding Different From Method Overloading?

Answer»

When overriding a method, you CHANGE the behavior of the method for the derived class. OVERLOADING a method simply involves having another method with the same NAME WITHIN the class.

When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.

104.

What Does The Keyword "virtual" Declare For A Method Or Property?

Answer»

The METHOD or PROPERTY can be OVERRIDDEN.

The method or property can be overridden.

105.

What's The Implicit Name Of The Parameter That Gets Passed Into The Set Method/property Of A Class?

Answer»

VALUE. The DATA type of the value PARAMETER is DEFINED by whatever data type the property is declared as.

Value. The data type of the value parameter is defined by whatever data type the property is declared as.

106.

What Is The Difference Between A Struct And A Class?

Answer»

Structs are value-type variables and are THUS saved on the STACK, additional overhead but FASTER retrieval. Another DIFFERENCE is that structs cannot inherit.

Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.

107.

What's The Difference Between An Interface And Abstract Class?

Answer»

In an interface class, all METHODS are abstract - there is no IMPLEMENTATION. In an abstract class some methods can be concrete. In an interface class, no ACCESSIBILITY modifiers are ALLOWED. An abstract class may have accessibility modifiers.

In an interface class, all methods are abstract - there is no implementation. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers.

108.

What Happens If You Inherit Multiple Interfaces And They Have Conflicting Method Names?

Answer»

It’s up to you to implement the method inside your own CLASS, so IMPLEMENTATION is left entirely up to you. This might cause a problem on a higher-level scale if SIMILARLY named methods from different interfaces EXPECT different data, but as far as compiler cares you’re okay.
To Do: Investigate.

It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
To Do: Investigate.

109.

Can You Inherit Multiple Interfaces?

Answer»

YES. .NET does SUPPORT MULTIPLE INTERFACES.

Yes. .NET does support multiple interfaces.

110.

Why Can't You Specify The Accessibility Modifier For Methods Inside The Interface?

Answer»

They all MUST be PUBLIC, and are THEREFORE public by DEFAULT.

They all must be public, and are therefore public by default.

111.

What Is An Interface Class?

Answer»

INTERFACES, like classes, define a set of properties, METHODS, and events. But unlike classes, interfaces do not PROVIDE implementation. They are implemented by classes, and defined as separate ENTITIES from classes.

Interfaces, like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation. They are implemented by classes, and defined as separate entities from classes.

112.

When Do You Absolutely Have To Declare A Class As Abstract?

Answer»

1. When the CLASS itself is INHERITED from an abstract class, but not all base abstract METHODS have been overridden.
2. When at least one of the methods in the class is abstract.

1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2. When at least one of the methods in the class is abstract.

113.

What's An Abstract Class?

Answer»

A CLASS that cannot be instantiated. An abstract class is a class that must be INHERITED and have the methods overridden. An abstract class is essentially a blueprint for a class WITHOUT any IMPLEMENTATION.

A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.

114.

Can You Allow A Class To Be Inherited, But Prevent The Method From Being Over-ridden?

Answer»

Yes. Just leave the class public and MAKE the METHOD SEALED.

Yes. Just leave the class public and make the method sealed.

115.

Can You Prevent Your Class From Being Inherited By Another Class?

Answer»

YES. The KEYWORDSEALED” will prevent the class from being INHERITED.

Yes. The keyword “sealed” will prevent the class from being inherited.

116.

What Is The Syntax To Inherit From A Class In C#?

Answer»

PLACE a COLON and then the NAME of the BASE class.
Example: class MyNewClass : MyBaseClass.

Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass.

117.

If A.equals(b) Is True Then A.gethashcode & B.gethashcode Must Always Return Same Hash Code.

Answer»

The answer is False because it is given that A.equals(B) RETURNS true i.e. objects are equal and now its hash Code is asked which is ALWAYS independent of the fact that whether objects are equal or not. So, GET HashCode for both of the objects returns different value.

The answer is False because it is given that A.equals(B) returns true i.e. objects are equal and now its hash Code is asked which is always independent of the fact that whether objects are equal or not. So, Get HashCode for both of the objects returns different value.

118.

Explain The Three Services Model Commonly Know As A Three-tier Application.

Answer»

Presentation (UI), Business (logic and underlying CODE) and DATA (from STORAGE or other SOURCES).

Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

119.

Can Multiple Catch Blocks Be Executed For A Single Try Statement?

Answer»

No. Once the PROPER CATCH block PROCESSED, control is transferred to the FINALLY block (if there are any).

No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

120.

What's The C# Syntax To Catch Any Possible Exception?

Answer»

A catch BLOCK that catches the exception of type System.Exception. You can ALSO OMIT the PARAMETER data type in this case and just write catch {}.

A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

121.

Will The Finally Block Get Executed If An Exception Has Not Occurred?

Answer»

YES. FINALLY block always GET EXECUTED.

Yes. Finally block always get executed.

122.

What Class Is Underneath The Sortedlist Class?

Answer»

A SORTED HASHTABLE.

A sorted HashTable.

123.

What's The .net Collection Class That Allows An Element To Be Accessed Using A Unique Key?

Answer»

HASHTABLE, DICTIONARY, NameValueCollection.

HashTable, Dictionary, NameValueCollection.

124.

What's The Difference Between System.string And System.text.stringbuilder Classes?

Answer»

System.String is IMMUTABLE. System.StringBuilder was DESIGNED with the PURPOSE of having a MUTABLE string where a variety of operations can be PERFORMED.

System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

125.

What Does The Term Immutable Mean?

Answer»

The data value may not be CHANGED. NOTE: The variable value may be changed, but the ORIGINAL immutable data value was DISCARDED and a new data value was CREATED in memory.

The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.

126.

What's The Top .net Class That Everything Is Derived From?

Answer»

System.Object.

System.Object.

127.

Describe The Accessibility Modifier "protected Internal".

Answer»

It is AVAILABLE to classes that are within the same ASSEMBLY and DERIVED from the SPECIFIED base class.

It is available to classes that are within the same assembly and derived from the specified base class.

128.

Are Private Class-level Variables Inherited?

Answer»

YES, but they are not ACCESSIBLE. Although they are not visible or accessible VIA the class interface, they are inherited.

Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

129.

Who Is A Protected Class-level Variable Available To?

Answer»

It is AVAILABLE to any sub-CLASS (a class INHERITING this class).

It is available to any sub-class (a class inheriting this class).

130.

Does C# Support Multiple-inheritance?

Answer»

No, but you can IMPLEMENT more than ONE INTERFACES.

No, but you can implement more than one interfaces.

131.

Can A Static Class Contain Non Static Members?

Answer»

No, a STATIC CLASS can CONTAIN only static MEMBERS.

No, a static class can contain only static members.

132.

Can You Create An Instance Of A Static Class?

Answer»

No, you cannot CREATE an INSTANCE of a STATIC CLASS.

No, you cannot create an instance of a static class.

133.

Classes And Structs Can Be Declared As Static, Is This Statement True Or False?

Answer»

FALSE, only CLASSES can be DECLARED as STATIC and not STRUCTS.

False, only classes can be declared as static and not structs.

134.

How Do You Prevent A Class From Being Inherited By Another Class?

Answer»

USE the sealed KEYWORD to prevent a class from being INHERITED by ANOTHER class.

Use the sealed keyword to prevent a class from being inherited by another class.

135.

Can You Create An Instance For An Abstract Class?

Answer»

No, you cannot CREATE an INSTANCE for an ABSTRACT CLASS.

No, you cannot create an instance for an abstract class.

136.

If A Class Derives From Another Class, Will The Derived Class Automatically Contain All The Public, Protected, And Internal Members Of The Base Class?

Answer»

YES, the derived class will AUTOMATICALLY contain all the PUBLIC, protected, and internal members of the BASE class except its constructors and destructors.

Yes, the derived class will automatically contain all the public, protected, and internal members of the base class except its constructors and destructors.

137.

Classes And Structs Support Inheritance. Is This Statement True Or False?

Answer»

False, Only classes SUPPORT INHERITANCE. STRUCTS DONOT support inheritance.

False, Only classes support inheritance. structs donot support inheritance.

138.

If You Donot Specify An Access Modifier For A Method, What Is The Default Access Modifier?

Answer»

private.

private.

139.

List The 5 Different Access Modifiers In C#?

Answer»

1. public
2. protected
3. internal
4. protected internal
5. PRIVATE

1. public
2. protected
3. internal
4. protected internal
5. private

140.

When Do You Generally Use A Class Over A Struct?

Answer»

A class is used to model more complex BEHAVIOR, or DATA that is INTENDED to be modified after a class object is CREATED. A struct is best suited for SMALL data structures that contain primarily data that is not intended to be modified after the struct is created.

A class is used to model more complex behavior, or data that is intended to be modified after a class object is created. A struct is best suited for small data structures that contain primarily data that is not intended to be modified after the struct is created.

141.

What Do You Mean By Saying A "struct Is A Value Type"?

Answer»

A STRUCT is a value TYPE mean when a struct is created, the variable to which the struct is assigned holds the struct's actual data. When the struct is assigned to a NEW variable, it is copied. The new variable and the original variable therefore contain TWO separate copies of the same data. CHANGES made to one copy do not affect the other copy.

A struct is a value type mean when a struct is created, the variable to which the struct is assigned holds the struct's actual data. When the struct is assigned to a new variable, it is copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy do not affect the other copy.

142.

What Do You Mean By Saying A "class Is A Reference Type"?

Answer»

A class is a REFERENCE type means when an object of the class is created, the VARIABLE to which the object is assigned holds only a reference to that MEMORY. When the object reference is assigned to a NEW variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both REFER to the same data.

A class is a reference type means when an object of the class is created, the variable to which the object is assigned holds only a reference to that memory. When the object reference is assigned to a new variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both refer to the same data.

143.

What Is The Base Type From Which All Structs Inherit Directly?

Answer»

All STRUCTS INHERIT DIRECTLY from System.ValueType, which INHERITS from System.Object.

All structs inherit directly from System.ValueType, which inherits from System.Object.

144.

Are Structs Value Types Or Reference Types?

Answer»

STRUCTS are VALUE TYPES.

Structs are value types.

145.

Can A Struct Inherit From An Interface In C#?

Answer»

Yes.

Yes.

146.

Can A Struct Inherit From Another Struct Or Class In C#?

Answer»

No, a STRUCT cannot INHERIT from ANOTHER struct or CLASS, and it cannot be the BASE of a class.

No, a struct cannot inherit from another struct or class, and it cannot be the base of a class.

147.

Can You Instantiate A Struct Without Using A New Operator In C#?

Answer»

YES, you can INSTANTIATE a struct without using a NEW operator.

Yes, you can instantiate a struct without using a new operator.

148.

Can A Struct Have A Default Constructor (a Constructor Without Parameters) Or A Destructor In C#?

Answer»

No.

No.

149.

Does C# Support Multiple Class Inheritance?

Answer»

No, C# supports single class INHERITANCE only. HOWEVER CLASSES can implement MULTIPLE interfaces at the same time.

No, C# supports single class inheritance only. However classes can implement multiple interfaces at the same time.

150.

What Is The Main Advantage Of Using Inheritance?

Answer»

CODE REUSE.

Code reuse.