DuraSoft  TechLet 05, 2003

In this issue

Welcome to the May 2003 TechLet. If you have received this through some one you know and would like to subscribe directly for our future issues, please send an email to techlet@durasoftcorp.com with a subject subscribe. This subscription currently is absolutely free.

In this issue, we have a detailed article on "Inner Classes in Java and C#"

Message from us

If you like any question to be addressed or topic to be discussed, please send us an email to techlet@durasoftcorp.com. At the end of the year, one person will be randomly selected from the list of respondents for a special prize. We would like to hear from you.

Please send suggestions, corrections and comments to techlet@durasoftcorp.com.

If you are a VS.NET user, you may be interested in VS.NET Code Editing Tips and Tricks - 25 ways to improve Productivity.

In depth

Inner Classes in Java and C# Inner classes in Object-oriented languages have a defined distinction of making a developer strengthen his fundamentals or completely shake his basics in the language. But what happens to the person who wants to know the details of inner classes in more than one language? This article brings out the use of inner classes in Java and C#, in an attempt to throw light on the difference in implementation of various concepts. The complete article can be found at http://www.durasoftcorp.com/download

Quiz corner

 Assume that I have a class Base whose constructor looks like this:

            public Base()

            {

                  foo();

            }

where foo is a method that may be overridden by a derived class if desired. The body of the foo method contains no code (empty). Also,

I have a class named Derived which inherits from the above mentioned

class. It has one field

 

            private SomeClass obj = new SomeClass();

where SomeClass is a class with a method named “method.”

Derived overrides the base class method foo with the following

implementation:

           obj.method();

 

Now, what is the effect of creating an object of Derived using

           new Derived();

Send your response to techlet@durasoftcorp.com, and you may become the winner of this year's TechLet special prize.


Quiz from the past issue

This one should be easy. Given the following Java code exerpt:

        {
               foo(); // foo may throw an Exception
               doSomeThing();
 
               doSomeThingElse(); //... rest of the code
        }

I want doSomeThing() to be executed irrespective of whether foo throws an exception or not. What is the minimal code I should write to achieve this?

Answer!

Thanks to those who wrote to us with a response to this quiz. Your names have been entered for the year end drawing! Surprisingly none of the responses received initially were correct! Almost every one consistently said write a catch and finally. While the hope was sliming down, Craig, one of our new subscribers, finally came with the correct answer!

The answer is:

        {
               try
               {
                   foo(); // foo may throw an Exception
               }
               finally
               {
                   doSomeThing();
               }
 
               doSomeThingElse(); //... rest of the code
        }

 

Thus spake...

I hear and I forget. I see and I remember. I do and I understand. - Confucius.