buy domain website and hosting


ASP.NET Questions and Answers Set-9

Languages and Programming

Qus: How do I make it so that code runs when the security system is stopping it?

Ans: Security exceptions occur when code attempts to perform actions for which it has not been granted permission. Permissions are granted based on what is known about code; especially its location. For example, code run from the Internet is given fewer permissions than that run from the local machine because experience has proven that it is generally less reliable. So, to allow code to run that is failing due to security exceptions, you must increase the permissions granted to it. One simple way to do so is to move the code to a more trusted location (such as the local file system). But this won't work in all cases (web applications are a good example, and intranet applications on a corporate network are another). So, instead of changing the code's location, you can also change security policy to grant more permissions to that location. This is done using either the .NET Framework Configuration tool or the code access security policy utility (caspol.exe). If you are the code's developer or publisher, you may also digitally sign it and then modify security policy to grant more permissions to code bearing that signature. When taking any of these actions, however, remember that code is given fewer permissions because it is not from an identifiably trustworthy source—before you move code to your local machine or change security policy, you should be sure that you trust the code to not perform malicious or damaging actions.

Qus: How do I administer security for my machine? For an enterprise?

Ans: The .NET Framework includes the .NET Framework Configuration tool, an MMC snap-in (mscorcfg.msc), to configure several aspects of the CLR including security policy. The snap-in not only supports administering security policy on the local machine, but also creates enterprise policy deployment packages compatible with System Management Server and Group Policy. A command line utility, CASPol.exe, can also be used to script policy changes on the computer. In order to run either tool, in a command prompt, change the current directory to the installation directory of the .NET Framework (located in %windir%\Microsoft.Net\Framework\v1.0.2914.16\) and type mscorcfg.msc or caspol.exe.

Qus: What’s the implicit name and type of the parameter that gets passed into the class’ set method?

Ans: Value, and it’s data type depends on whatever variable we’re changing.

Qus: How do you inherit from a class in C#?

Ans: Place a colon and then the name of the base class. Notice that it’s double colon in C++.

Qus: Does C# support multiple inheritance?

Ans: No, use interfaces instead.

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

Ans: Classes in the same namespace.

Qus: Are private class-level variables inherited?

Ans: Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

Qus: Describe the accessibility modifier protected internal.

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

Qus: C# provides a default constructor for me. I write a constructor that akes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?

Ans: Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.

Qus: What’s the top .NET class that everything is derived from?
Ans: System.Object .

Qus: How’s method overriding different from overloading?

Ans: When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.

Qus: What does the keyword virtual mean in the method definition?
Ans: The method can be over-ridden.

Qus: Can you declare the override method static while the original method is non-static?
Ans: No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

Qus: Can you override private virtual methods?
Ans: No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.

Qus: Can you prevent your class from being inherited and becoming a base class for some other classes?

Ans: Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.

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

Ans: Yes, just leave the class public and make the method sealed.

Qus: What’s an abstract class?

Ans: 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.

Qus: When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?
Ans: When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.

Qus: What’s an interface class?
Ans: It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.

Qus: Why can’t you specify the accessibility modifier for methods inside the interface?
Ans: 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.

Qus: Can you inherit multiple interfaces?
Ans: Yes, why not.

Bookmark and Share




Gallery

Related Topics

Comments



Submit Reviews:


(Enter the characters seen on the image below.)



Promotional Ads

Advertisement

Packers and Movers in Chandigarh
Plot No 636, Near HP Gas Agency, Dariya, Chandigarh - 160101
Plot No 636, Near HP Gas Agency, Dariya, Chandigarh - 160101
Delhi

Maharaja Agrasen Hospital Super Speciality Hospital in Dwarka
H3VH+C7Q, Pocket 4, Sector 1 Dwarka, New Delhi 110075
Delhi

GET DIPLOMA IN DRESS DESIGNING| CONTACT-9810450615
A-100 3rd Floor, Mohan Garden, Nawada, opposite metro pillar no.747, near Uttam Nagar.
Delhi

PRIMARY TEACHER TRAINING(PTT)| SIPVS UTTAM NAGAR
A-100 3rd Floor, Mohan Garden, Nawada, opposite metro pillar no.747, near Uttam Nagar.
Delhi

Aplonis Healthcare
SCF-461, 1st floor
Motor Market, Sector-13,
Delhi

Jaggery Powder
431, Vijaya Lodge Building, Rangai Gowder Street, Town Hall, Coimbatore-641001, Tamil Nadu, India, Town Hall, Coimbatore-641001, Tamil Nadu, India
Coimbatore
Delhi

Self Drilling Anchor Bolt Systems
F-418 Office Block City Centre Mall Siliguri West Bengal - 734010
F-418 Office Block City Centre Mall Siliguri West Bengal - 734010
Delhi

Assured low-cost full body checkup at your home.
Mayur Colony, Kothrud
Pune
Delhi

HP Laptop Service Center in Dilshad Garden
197 B, Pocket F, Dilshad Gardenn Delhi,
Delhi

Interior A to Z
284/4, Chhatarpur Extension, Chhatarpur, New Delhi, Delhi 110074
Delhi
Delhi