Brainteaser: Overridable methods

Consider the following case of inheritance:

public class  Parent {
   public Parent()  {
	getValue();
   }
   public void getValue()  {

   }
}

public class  Child extends Parent {
   private final Integer integer;
   public Child()  {
	integer = new Integer(888);
   }

   @Override
   public void getValue()  {
	System.out.println(integer);
   }
}

Question: What would the following program print, why?

public class  Test {
   public static void main(String[] args)  {
	Child child = new Child();
	child.getValue();
   }
}

Lets assume that getValue() implementation in Child class was changed to:

@Override
public void getValue()  {
     System.out.println(integer.toString());
}

Question: What would the output of the Test class be now, why?

Online PDF Generator

Online PDF generator now available. This simple but useful online PDF generator tool allows you to generate PDF document online from HTML snippets. The tool uses Flying Saucer library.

The PDF is generated with full compression, including meta data in PDF properties. Keep in mind that for successful PDF generation, your HTML markup has to validate as XHTML 1.0 Transitional, which means <img> becomes <img /> or <p> must be terminated by the matching </p>.

You can provide URL to your own CSS file with styles for your HTML snippet or to provide a “style” attribute on HTML elements. If URL or “style” attribute are not specified, default system styles will be applied on your HTML snippet.

I hope this helps.

Cheers

Export Pebble Blog Entry to PDF Plugin

In one of my previous posts, I described how I implemented a plug in for Pebble blogging software that allows export of blog entries to PDF.

Today, I have made modifications to enable plug in to load font files at run time during PDF generation to provide support for additional non-Latin languages. So now, it is possible to export non-Lain characters from blog entries to PDF.

Below, I’ve added some content using different languages. To allow support for non-Latin languages, I am using font file cyberbit.ttf by Bitstream. You can test the plugin’s multilingual support by generating PDF from the current post.

I think its comes out quite nicely. The only hitch at this moment is that Flying Saucer does not have support for right-to-left text in PDF yet.

Japanese Kanji:
五輪代表

Japanese Hiragana
こんにちは、これは真実を決定するためにはテストテキストです。

Japanese Katakana
ラドクリフ、マラソン

Japanese Kokuji
和製漢字

Chinese Simplified:
您好,这是一个测试文本,以确定事实真相

Chinese Traditional:
您好,這是一個測試文本,以確定事實真相

Korean:
안녕하세요,이 사실을 확인하는 테스트 텍스트입니다

Arabic:
مرحبا ، هذا هو اختبار لتحديد نص الحقيقة

Hebrew:
שלום, זוהי בדיקה טקסט כדי לקבוע את האמת

Russian:
Привет, это тест текста, чтобы определить истину

Greek:
Γεια σας, αυτό το κείμενο είναι μια δοκιμασία για τον προσδιορισμό της αλήθειας

Thai:
สวัสดีนี่คือการทดสอบข้อความเพื่อตรวจสอบความจริง

Vietnamese:
Xin chào, đây là một bài kiểm tra văn bản để xác định sự thật

Turkish:
Merhaba, bu gerçeği belirlemek için bir test metin

Brainteaser: Broken Case of Inheritance

Consider the following case of inheritance:

public class ExtendingHashSet<E> extends HashSet<E>  {
   private int counter = 0;

   public ExtendingHashSet() {

   }

   @Override
   public boolean add(E e)  {
      counter++;
      return super.add(e);
   }

   @Override
   public boolean addAll(Collection&lt;? extends E&gt; c)  {
      counter += c.size();
      return super.addAll(c);
   }

   public int getCounter()  {
      return counter;
   }
}

Created instance:

ExtendingHashSet<String> s = new ExtendingHashSet<String>();
s.addAll(Arrays.asList("one", "two", "three"));

Question: What value would s.getCounter() method return at this point and why?

Looking forward for your answers dear readers

How bad the recession is affecting IT industry these days?

Within last three weeks, two of my friends living in UK called me with the same question: “How bad is recession in IT industry in Australia? I am thinking to migrate“. One guy from Brazil that I know emailed me: “Hey, I am lodging my application for permanent residency in Australia“… Hm… I know world is going through recession, but is it that bad in some countries?

Australia has it tough these days also. A lot of people lose their jobs, companies afraid to engage in projects that will not yield any revenue. Just now as I was typing this post, i overheard the news that around 700,000 people expected to lose their jobs in Australia this year. One of my ex-colleagues that was laid off last December is still jobless…

I would like to ask you dear readers -
How is the situation in your countries?
How tough IT guys have it these days?

Yeah, I think 2009 is not promising anything good, and worse is yet to come…. Hm… a bit on a grim note here