free classified ads and leads
domain website price


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 Mohali
Plot No 636, Near HP Gas Agency, Dariya, Chandigarh - 160101
Mohali

Submersible Sludge Pumps
18, shreenath Estate, cross road, nr. Nikol, nr. Sardar Patel Ring Road, Kathwada, Gujarat 382415
Ahmedabad

Bhakti Bird Proofing
House no.9479 durgamata tekdi vibhag, mahalaxmi nagar, City ambernath, Near durgamata temple. Pin Code-421501
Motilal Nagar Mumbai

Livonta Global Pvt.Ltd
1110, Colonnade, B/H Iscon Temple, Opp. Iscon BRTS Bus Stand
Iscon - Ambali Rd,
Ahmedabad

Brij Agnihotri & associates company secretaries
3454, 40D, Sector 40D, Chandigarh, 160036, India

JB Rock Bolts & SN BOLTS
10 A & B Industrial Area (at Vill. Nangal Jarialan)
Distt. Una Himachal Pradesh
Una

Govinda resorts Lonavala
Old Mumbai - Pune Hwy, Maval, Lonavala, Maharashtra 410405
Lonavla

Steelco Metal & Alloys
192 – Minara Mansion, Shop No.6, Sant Sena Maharaj Marg, 2nd Kumbharwada Lane, Mumbai, Maharashtra 400004
Mumbra Mumbai

Best Resorts in Dharamshala Amid the Misty Hills.
SATOBARI HILLS ROAD,MCLEODGANJ,
Dharamshala

Genius Global School
194 Anand Vihar Saproon, Solan, Himachal Pradesh
Ambala Cantt