The Question of the Day

Part of the You Can Learn ASP.Net and C# series.
By Ken Brown
Editor, YouCanLearnSeries.com
Updated:
January 13, 2007

Question of the Day

How do you designate a method as Abstract?

Answers from January 13, 2007 - Question of the Day

What is the visibility of a member declared as public?

Public designation allows a member to be accessed by the member methods of other classes.

Answers from January 6, 2007 - Question of the Day

Should you wrap unboxing operations in a try block?

Typically, you will wrap an unbox operation in a try block. If the object being unboxed is null or a reference to an object of a different type, then an InvalidCastException is thrown.

Answers from December 26, 2006 - Question of the Day

Where are reference types kept?

Reference types are kept on the heap.

Answers from December 18, 2006 - Question of the Day

How do you unbox an object?

You accomplish unboxing an object in 2 steps.
  1. Make sure the object instance is a boxed value of the given value type.
  2. Copy the value from the instance to the value-type value.
The object being unboxed must be of the appropriate type for the assigned variable.

Answers from December 17, 2006 - Question of the Day

Where are value types kept?

Value types such as integers are kept on the stack.

Answers from July 8, 2006 - Question of the Day

What does making one or more methods of a class abstract force the class to be?

Making one or more methods of any class abstract has the side effect of making the class abstract.

Answers from June 29, 2006 - Question of the Day

Does an abstract method have an implementation?

An abstract method has no implementation. It creates a method name and signature that must be implemented in all derived classes.

Answers from June 28, 2006 - Question of the Day

Is unboxing an explicit or implicit conversion?

To return the boxed object back to a value type, you must explicitly unbox it.

Answers from June 27, 2006 - Question of the Day

What is boxing and unboxing in the C# language?

Boxing and unboxing are the processes that enable value types (e.g., integers) to be treated as reference types (objects). The value is boxed inside an object, and subquently unboxed back to a value type.

Answers from June 26, 2006 - Question of the Day

How is Polymorphism implemented in a method of a base class?

To create a method that supports polymorphism, you need only mark it as virtual in its base class.
public virtual void SupportPoly()

Answers from June 21, 2006 - Question of the Day

How can you restrict the visibility of a class and its members?

You can restrict the visibility of a class and its members through the use of access modifiers, such as: private, public, protected, internal and internal protected.

Answers from June 20, 2006 - Question of the Day

When the keyword new appears in code, what should it do?

When the keyword new appears in code, it should document the versioning of code. It points a potential client to the base class to see what you aren't overriding. Using new scattershot undermines this documentation. Further, the warning exists to help identify a real issue.

Answers from June 13, 2006 - Question of the Day

What is the root of all classes?

All C# classes, of any type, are treated as if they ultimately derive from System.Object. This includes value types.

Previous Questions of the Day

Answers from June 12, 2006 - Question of the Day

What keyword can you use to require subclasses to implement a method of their base?

To require subclasses to implement a method of their base, you need to designate that method as abstract in the base class.

Answers from June 9, 2006 - Question of the Day

How does the keyword override help to prevent breaking existing code in derived classes?

In C#, a virtual function is always considered to be the root of virtual dispatch. Once C# finds a virtual method, it looks no further up the inheritance hierarchy.

Answers from June 8, 2006 - Question of the Day

What is a sealed class?

A sealed class doesn't allow classes to derive from it at all. Placed before the class declaration, the sealed keyword precludes derivation. Classes are most often marked sealed to prevent accidental inheritance.

Answers from June 7, 2006 - Question of the Day

Is it okay to instantiate an object of an abstract class?

Abstract classes establish a base for derived classes,but it is not legal to instantiate an object of an abstract class.

Once you declare a method to be abstract, you prohibit the creation of any instances of that class.

Answers from June 6, 2006 - Question of the Day

If a base class has an accessible default constructor, is the derived constructor required to invoke the base constructor?

No, if a base class has an accessible default constructor, the derived constructor is not required to invoke the base constructor explicitly. The default constructor is called implicitly.

Answers from June 5, 2006 - Question of the Day

What is the visibility of a member declared as internal?

The keyword internal extends visibility to methods of any class in the same assembly (DLL).

Answers from June 1, 2006 - Question of the Day

If a base class of a derived class does not have a default constructor; what must the derived constructor do?

If the base class does not have a default constructor, every derived constructor must explicitly invoke one of the base class constructors using the base keyword.

Answers from May 31, 2006 - Question of the Day

How is polymorphism implemented in a method of a base class?

Simply override the base class virtual method by using the keyword override in the derived class method definition and add the new code for the overridden method.

public override void BaseMethod(){}

Answers from May 30, 2006 - Question of the Day

How does a derived class invoke the constructor of its parent class (ListBox)?

The derived class constructor invokes the constructor of its parent by placing a colon (:) after the parameter list and then invoking the base class with the keyword base.

public ListBox( int top, int left) : base ( parentTop, parentLeft )


Home| About Us | NewsLetters | Contact Us |

Copyright © 2004-2014 You Can Learn Series

You Can Learn Series Home Page You Can Learn Series
You Can Learn Series Home Page Home            About the creators of YouCanLearnSeriesAbout Us      Contact YouCanLearnSeriesContact Us      Site map of YouCanLearnSeriesSite Map      Privacy Policy of You Can Learn SeriesPrivacy Policy       Terms of Use of You Can Learn Series web siteTerms of Use       YouCanLearnSeries RSS feed for C# tips and tutorials     
C# and ASP.Net Programming TipsC# and ASP.Net      SQL Tutorial, tips and tricks for DBA'sSQL       Landscaping Tips for Home GardenersLandscaping       WeightLifting Tips for the Young and OldWeightLifting       Kennos BlogBlog       Good health TipsGoodHealth       Learn about Great Travel DestinationsTravel     Web Business TipsWeb Business            You Can Learn Series' Online StoreStore



You Can Learn C# and ASP.Net SeriesC# and ASP.Net
  Using Client Side Code with C# and ASP.NetClient Side Code
  Using Client Side State Management with C# and ASP.NetClient Side State Management
  Create a C# Class in Visual StudioCreate A Class
  Use A Class in C#Use A Class
  Create a Solution in Visual StudioCreate a Solution
  Create a Project in Visual StudioCreate a Project
  Create an RSS feed for your Web SiteCreate an RSS Feed
  Create an RSS feed for your Web SiteListItemCollection
  Set Events in ASP.NetSet Events ASP.Net
  Set Events in C#Set Events C#
  What is Session State and How to Use it.Session State
  Creating and Using the C# SortedList ObjectSortedList Object
  Stylesheet Tips for Visual Studio .Net and ASP.NetStyleSheet Tricks
  Using C# MethodsUsing Methods
  Pass Objects to MethodsPass Objects to Methods
  Pass Objects from MethodsPass Objects from Methods
  Using Client side State management like ViewState and Hidden fieldsView State
  LDAP, What is Lightweight Directory Access ProtocolWhat is LDAP
  Build an LDAP ReaderBuild an LDAP Reader
  Convert information from LDAP to a Web ServiceLDAP To Web Service
  Question of the dayQuestion of the Day

You Can Learn SQL SeriesSQL
You Can Learn Landscaping and Gardening SeriesLandscape Tips
You Can Learn WeightLifting SeriesWeightLift Tips
Kenno's BlogBlog
You Can Learn Good Health SeriesGood Health Tips
You Can Learn Good Series NewslettersNewsletters
Learn about Great Travel DestinationsTravel
You Can Learn Series Web Business TipsWeb Business Tips
Merchandise Available from You Can Learn SeriesMerchandise

Bill Welter - The Prepared Mind of a Leader




Americas Public Schools