Dot Net Interview Questions and Answers Part 28

(Q). Can we consume a class of a project from a class of the same project?

Ans:- yes. We can consume them directly as were under same project, and were considered as a family.

(Q). Can we consume a class of a project from a class of another project?

Ans: -Yes. We can consume but not directly as they were under different project and first need to add reference of the assembly in which the class was present to the project who what’s to consume it.

(Q). How to add reference of an assembly to a project?

Ans:- To add reference of an assembly to a project open Solution Explorer right click on the project to when reference has to be added and select “Add reference” which open window select “Browse” option on the top & select an assembly from its physical location and click ok. Now we can consume classes of the assembly referring with their namespace.

(Q).How to restrict a class not to be accessible to any other class?

Ans: -This can be done by declaring constructor of class as private.

(Q). How to restrict a class not to be inherited by any other class?

Ans: - This can be done by declaring class as sealed.

(Q). How to restrict a class not to be accessible for any other class to consume by creating its object?

Ans: -This can be done by declaring constructor of the class as protected.



Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker