.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> .NET Framework >> Post New Question Subscribe to Interview Questions

Are private class-level variables inherited?

Posted By :Vinodh     Posted Date :September 19, 2011    Points :40   Category :.NET Framework 
Yes,private class members are inheritable, but they are not accessible

You can also find related Interview Question to Are private class-level variables inherited?  below: 

Are private class-level variables inherited?

Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are. (More...)

Are private class-level variables inherited?

Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are. (More...)

What is Private Constructor? and it's use? Can you create instance of a class which has Private Constructor?

When a class declares only private instance constructors, it is not possible for classes outside the program to derive from the class or to directly create instances of it. (Except Nested classes)
Make a constructor private if:

1) You want it to be available only to the class itself. For example, you might have a special constructor used only in the implementation of your class' Clone method.

2) You do not want instances of your component to be created. For example, you may have a class containing nothing but Shared utility functions, and no instance data. Creating instances of the class would waste memory. (More...)

How can I look up a parent class method or property of any System-level object?

Use the Class View window, accessed from the standard toolbar by clicking View | Class View. (More...)

Can you allow class to be inherited, but prevent the method from being over-ridden?

Yes, just leave the class public and make the method sealed. (More...)

Whether we can create a private constructor for a class?

Yes it is possible. we can create a private constructor for a class (More...)

Can namespace contain the private class?

no, having a single private class does not mean anything , it is applicable only in case of nested class.

How can you access a private method of a class?

Use .Net Reflection. Using reflection we can invoke private methods too.


Car car = new Car();
Type type = car.GetType();
MethodInfo methodInfo = type.GetMethod("ShiftGearUp", BindingFlags.NonPublic | BindingFlags.Instance);
methodInfo.Invoke(car, null);

Pre: Create a class Car with private method "ShiftGearUp" (More...)

How to block a class from being inherited further?

Use sealed keyword.

Eg: public sealed class TheClass
} (More...)

In which order the constructor is called for an inherited class?

Constructor of Parent class is called


Constructor of Child class (More...)

In WCF, suppose you have a derived class inherited from a datacontract class, will the derived class automatically have a datacontract as well ?

The Data contract is not inherited, so any derived class, would have to be explicitly declared as having a Data contract attribute as well.


Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend