C# Interview Questions with Answers Pdf - 1

Question: 1

How is method overriding different from overloading?

When overriding, you change the method behavior for a derived class.

Overloading simply involves having a method with the same name within the class.

Question: 2

What is an abstract class?

A class that cannot be instantiated.

A concept in C++ known as pure virtual method.

A class that must be inherited and have the methods over ridden.

Essentially, it’s a blueprint for a class without any implementation.

Question: 3

Are private class level variables inherited?

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

Question: 4

What is the advantage of using system.Text.StringBuilder over System.String?

StringBuilder is more efficient in cases where there is a large amount of string manipulation.

Strings are immutable, so each time a string is changed, a new instance in memory is created.

Question: 5

What is the syntax to inherit from a class in C#?

Place a colon and then the name of the base class.

Example: class MyNewClass: MyBaseClass

Related Questions