Static block initialization

Recently, my friend Chandru came up with a new problem in java.

Try solving the below problem without java.exe 🙂

public class StaticUnderstanding {
	public static void main(String[] args) {
class SuperClass {
	static {
		System.out.println("In superclass...");
	protected static void dummyMethod(){
		System.out.println("In dummy method...");
class SubClass extends SuperClass {
	static {
		System.out.println("In subclass...");

If you come with any answer other than the below, then you need to read  JLS 12.4 – Initialization of Classes and Interfaces.

In superclass…

In dummy method…

Thanks to Sai for getting this awesome data !!

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine


Subnet address from slash notation to dot notation

Few weeks back I attempted to write a program that converts subnet address in slash notation to dot notation. Though answers using if/switch statements came to my mind, I am not pretty convinced with those. I like to follow the KISS principle here. Continue reading

Is a number Power of Two

Last week, I was reading through an article written by Bill Venners (don’t read this now). Though the purpose of the article is to highlight some of the key interviewing techniques, I was excited by Josh Bloch question, “Finding is a number power of 2”. Continue reading

Playing with REST annotations

In the last article in addition to setting up our IDE for writing REST services we have also got friendly with four basic annotations. In this article we will look in to some of the other commonly used annotations in REST. Continue reading

Finding IPAddress belongs to same subnet

             We (me, Sree Pratheep, Parthi) along with some of our friends will usually go out for Sunday dinner. Last week Senthil joined us and made the dinner a special occassion:).We went to Tummy Full @ Velachery, Chennai, India. As a regular trend, they too have some puzzles in the table paper to be solved. But these guys went a step ahead and provided us with a Pencil, awesome perfect customer engagement!! This kindled my thought Continue reading

Incremental Code Coverage using Emma


We are working on a web based project. Due to the wide spread (and various other reason) we don’t have a complete automation for testing end-end functionality of the project. Recently, we have started using Emma to analyze the amount of code that is really being exercised. This is when we hit with a hard problem (at least from my perspective)

                How do we do incremental code coverage of a product during development – testing phase?

Continue reading

Function overloading – Compile time / Runtime ?

Is function overloading Compile time or Runtime? Does JVM has control over which overloaded method needs to be called or it is engraved in the class file itself. Simple question!!Yet often forgotten even by nerd java programmers.

Continue reading