Wednesday, May 6, 2009

Puzzle 21 – Solution

The key to the puzzle is 'static method can be called using an object reference.' The solution to this simple puzzle is:

Output – Static Method Print Statement called.
Reason - Static method can be called using object reference.

Sorry no correct answers this week.

Sunday, May 3, 2009

Puzzle 21 – Static This!

Language – Java | Type – Concept | Last date 06-May-2009 9:00 p.m. IST | Points 2

Does anyone really code like this? Anyone out here figure out what does this code do?
package com.twisters;
public class StaticThis {

public static void main(String[] args) {
new StaticThis().print();
}

public static void printStatement(){
System.out.println("Static Method Print Statement called.");
}

public void print() {
this.printStatement();
}
}
Got an answer? Why don’t you leave it here.

Puzzle 20 – Solution.

The key to the last puzzles solution is ‘getting hold of the super class variable in the child class constructor.’ The simplest way to do so is using the super keyword.

The code snippet that achieves this is super.a = 10.

Congrats to
1. Sathi
2. Anonymous
for getting the answer right.

Friday, May 1, 2009

Treasure Hunt - Post 1

Twister is a basic level quiz and I have been for some time thinking of something more advance. That’s what gets me to this post - a Java based Treasure Hunt.

Treasure hunts are always fun - especially if you don't have to run about in dense forest and ride tormenting seas :)

I still have not got everything in place - might be a few more weeks before everything is ready to roll - but I'll try and give you a fair idea about what this is going to be.
It's a treasure hunt - one clue will lead to another - until (or if) you finally find the treasure. The clues are not typical Java features and like most treasure hunts there would be more then one way to break the clues.

The story so far? "Legend has it that HeadHunter of the java.pirate.hunter band has kept this treasure hidden for over 10 years. But nothing can be hidden forever and rumor of The LINK have started to surface. As you well wishing friend and guide I offer you this adventure - something you have never seen before ..."

Keep watching this space for more...