DotNet FrameWork – Can Private class-level variables be inherited – Protected Internal – Can you write a class without specifying namespace – Day 9 of 30

When you inherit a protected class-level variable, who is it available to?

The derived class.

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.

Describe the accessibility modifier “protected internal”.

It is available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).

What’s the top .NET class that everything is derived from?

System.Object.

What’s 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 it’s being operated on, a new instance is created.

Can you store multiple data types in System.Array?

No.

What’s the .NET class that allows the retrieval of a data element using a unique key?

HashTable.

Will the finally block get executed if an exception has not occurred?

Yes.

What’s an abstract class?

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.

When do you absolutely have to declare a class as abstract?

1.When at least one of the methods in the class is abstract.

2.When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.

What’s an interface?

It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.

Why can’t you specify the accessibility modifier for methods inside the interface?

They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice,

you are not allowed to specify any accessibility, it’s public by default.

What’s the difference between an interface and abstract class?

In an interface class, all methods must be abstract. In an abstract class some methods can be concrete. In an interface class, no accessibility modifiers are allowed, which is ok in an abstract class.

Can you write a class without specifying namespace? Which namespace does it belong to by default?

Yes, you can, then the class belongs to global namespace which has no name. For commercial products, naturally, you wouldn’t want global namespace.

Please read all the post in the Dotnet Framework series.

Reference : Dilip Kumar Jena ( https://mstechexplore.wordpress.com )

Advertisements

One thought on “DotNet FrameWork – Can Private class-level variables be inherited – Protected Internal – Can you write a class without specifying namespace – Day 9 of 30

  1. Pingback: DotNet FrameWork – Dot Net Basics Complete Series Reference – Day 0 of 30 « Exploring Dot Net with Dilip Kumar Jena

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s