YouTube Icon

Interview Questions.

Top 100+ C# Oops Interview Questions And Answers - May 27, 2020

fluid

Top 100+ C# Oops Interview Questions And Answers

Question 1. Can You Allow A Class To Be Inherited, But Prevent A Method From Being Overridden In C#?

Answer :

Yes. By Declaring the class public and making the approach sealed.

Question 2. You Declare An Overridden Method To Be Static If The Original Method Is Not Static?

Answer :

No. Two virtual strategies have to have the equal signature.

C#. NET Interview Questions
Question three. Can You Inherit Private Members Of A Class?

Answer :

No, we cannot inherit personal participants of a category because private members are available handiest to that class and not out of doors that magnificence.

Question 4. Is It Possible To Execute Two Catch Blocks?

Answer :

No. Whenever, an exception takes place in your application, the proper capture block is achieved and the manipulate goes to the in the end block.

C#. NET Tutorial
Question five. Can You Prevent A Class From Overriding?

Answer :

Yes. You can save you a category from overriding in C# by means of the use of the sealed keyword; and in VB through the usage of NotInheritable keyword.

ASP.NET Interview Questions
Question 6. What Is 'this' Pointer?

Answer :

'this' pointer refers back to the contemporary object of a class.

Question 7. Can 'this' Be Used Within A Static Method?

Answer :

No.

ASP.NET Tutorial Microsoft Entity Framework Interview Questions
Question 8. Is It Possible For A Class To Inherit The Constructor Of Its Base Class?

Answer :

No. A elegance can't inherit the constructor of its base magnificence.

Question 9. What's The Difference Between The 'ref' And 'out' Keywords?

Answer :

An argument surpassed as "ref" need to be initialized earlier than passing to the approach whereas "out" parameter wishes no longer to be initialized earlier than passing to a way, and it'll be initialized in the approach.

LINQ Interview Questions
Question 10. Difference Between Const, Readonly And Static Readonly In C# ?

Answer :

Constant variables are declared and initialized at bring together time. The price can not be modified after phrases.
Readonly variables might be initialized most effective from the non-static constructor of the equal elegance.
Static Readonly variables will be initialized best from the static constructor of the same elegance.
Microsoft Entity Framework Tutorial
Question 11. What Is The Difference Between “dispose” And “finalize” Variables In C#?

Answer :

Dispose() Method

Dispose method will be used to unfastened unmanaged resources like files, database connection etc.
To clean unmanaged sources we want to put in writing code manually to elevate dispose() method.
This Dispose() approach belongs to IDisposable interface.
If we need to implement this method for any custom lessons we want to inherit the magnificence from IDisposable interface.
 Finalize() Method

Finalize technique also free unmanaged assets like database connections, documents and so forth.
It is routinely raised through rubbish collection mechanism on every occasion the object is going out of scope.
This approach belongs to object class.
We need to enforce this approach each time we have unmanaged resources in our code and ensure those resources could be freed while rubbish series technique done.
Framework7 Interview Questions
Question 12. Why To Use "the use of" Statement In C#?

Answer :

The the usage of block is used to achieve a aid and use it after which robotically dispose off whilst the execution of block completed.

C#. NET Interview Questions




CFG