Wednesday, June 9, 2010

Absolutely Singleton.....

Many of Java developers know about singleton pattern and how to create it. But, creating a thread safe Singleton is the real absolute singleton. Otherwise, there are chances for ending up with different objects for different threads, which is totally against singleton.

A sample program given in the discusion here clearly explains how a singleton which is not thread safe can create different objects w.r.t different threads.

Saturday, May 8, 2010

Servlet, JSP..

  • What is the difference between JSP and Servlet?
  • How can JSP and Servlet communicate with each other?
  • How to track an user? (Session and cookies)
  • How to create a session in servlets?
  • How will you implement a page counter using Jsp/Servlet? Where will you initialize the variable and where will it get incremented? What will happen to it, when the server crashes?
  • Do you have used any Servlet filters? What is a filter?
  • Can a servlet have a constructor? (No.)
  • Saturday, March 27, 2010

    Unix Questions

  • How to find and delete files older than a year in Unix?
  • Write the awk command print the 5th column of 'ls -l'?
  • What will be the default permissions of a file created in Unix?
  • How would you execute a script file and how to execute the script file from a different directoy?
  • Write the grep command to find pattern "Vinod" and "Vinney" from a file.
  • what is SED and AWK?
  • Adding Questions

  • What are the conditions underwhich finally() wont be called?
  • Differences between wait() and sleep()?
  • What is static/early binding and dynamic/late binding?
  • How to create user defined exceptions? How to use throw and throws?
  • What is synchrnization? What are threads and why do we need them?
  • Static block

    Updated on 8th May 2010

  • I have a design, which gets changed often. In this case, which is to be used either abstract class or interface?
  • Difference b/w wait() and sleep()?
  • Difference b/w Hashmap and Hashtable? How to synchronize my HashMap()?
  • Features in Java1.5
  • Difference b/w stringBuffer and stringBuilder?
  • Reflection
  • Saturday, February 20, 2010

    Interesting Questions....

  • What is the difference between NoclassDefFoundError and ClassNotFoundException?

  • Is it possible to declare a method in scriptlet? What is the use of declaration tag in JSP?
  • Friday, February 19, 2010

    JSP:Can a method be declared in scriptlets?

    Can we declare a method in scriptlets? If so, what is the use of declaration tag?
    If you want the answers, just Click here

    Tuesday, November 10, 2009

    Java Tasks

    Some questions to ponder over,

  • Write a program to get the first two integers in a array which sums up to a given value. An integer array is given and a sum value is given. You have to find the first two numbers in the array which can add to give given sum value. Example: Given array is {10,34,56,80,1,36,93,62,23,90,21} and sum is 155. In this case, 93 and 62 will be the values adding upto 155.


  • Write a program to reverse a string without using string buffer and string builder. Example " my name is vinod " should be reversed to "ym eman si doniv"


  • Write a boolean isChild(String parent, String child) method in java, which returns true if a child string is in parent string in the same order else false.
    Example1- parent1 - LOCAL,
    child1 - LOL
    returns true

    paren1 - CHANGE,
    child1 - AEC
    returns false


  •