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) {
		SubClass.dummyMethod();
	}
}
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

Bit support in Java (32 or 64 bit)

I came across a task to find out the bit support level in the installed java. This has to be done from the command line and the solution has to be unique across Solaris and Linux. I presumed it to be an easy problem, however it is not so. Below describes the different solution that I tried and the problems I faced in those
Read more »

Is Scala implicit conversions prevents auto boxing?

People following me on twitter know that I am in the phase of learning Scala for the past few days. As a java programmer I am comfortable with most of the aspects of Scala (though more to explore in coming days). Recently I came across a problem that gave me an impression that Scala fails in doing auto boxing. Read more »

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. Read more »

GNS3/Dynamips network simulator

If you are looking for any of below mentioned “How to” then the following five minutes screen cast will help you out

  1. How to start with Dynamips/GNS3
  2. How to emulate a switch using Dynamips/GNS3
  3. How to save configuration in Dynamips/GNS3

Almost a month after updated my blog with a short screencast. Hope many more articles will flow in soon. Let us know your further questions on Dynamips/GNS3 through comments.

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”. Read more »

My experiences with AWS Chennai workshop

Today (10-Nov-2009) I have experienced many new things in my life. First to mention, being an inhabitant of Chennai only after five years of industry experience, today is my first day to visit Tidel Park, Chennai.  Also today I have my first time exposure to Amazon Web Services (AWS). It is a good workshop that opened my eyes towards many new technical jargons. In this blog, I am trying to capture most of the items that are discussed today. Most of the things captured here are from my notes (or from top of my head), so they are going to be keywords rather than detailed explanations. Read more »

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. Read more »

Getting started with REST

Introduction

REST, acronym for Representational State Transfer is coined by Roy Fielding to represent architectural style of networked systems. This is not a standard but an architectural style for an application that is based on different standards like HTTP, XML, URL, MIME types.  JAX-RS specification, JSR 311 defines a set of java APIs for development of RESTful web services and RESTful java application.  Sun Jersey, JBoss RESTEasy, Apache CXF provides implementation for JSR 311. In this article we will look at the steps needed to setup Eclipse IDE for developing REST application using Jersey. We will also write our first HelloWorld service. Read more »

4 easy steps to load Strut2InAction source

Currently I am reading Struts 2 in Action. This is my second book from Manning publication. My first book was JQuery in Action which is awesome.  As I completed the second chapter in Struts 2 I like to try out the sample HelloWorld program.  So I downloaded the source code from manning website. I am able to play with HelloWorld in few minutes by deploying (copying) the downloaded war inside Tomcat 5.5.  However I also want to make a development setup in my eclipse so that I could try out certain things after changing the downloaded source. Unfortunately I am not able to make this easily. Read more »

Follow

Get every new post delivered to your Inbox.