Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

January 22, 2011

WebApps


Web applications allow compiled classes to be stored in both the /WEB−INF/classes and /WEB−INF/lib
directories. Of these two directories, the class loader will load classes from the /classes directory first,followed by the JARs in the /lib directory. If you have duplicate classes in both the /classes and /lib
directories, the classes in the /classes directory will take precedence.

January 9, 2011

Manage ( Enable / Disable ) startup programs in Windows Vista

You can Enable / Disable startup programs on your PC with Windows Vista by following the following simple steps :

1. Go to Control Panel  -> Windows Defender



2. Then go to Tools and then Software Explorer (as shown in the image below)

3. Make sure that the Category selected is 'Startup Programs'.

Then select the program that you want to Disable or Remove and click the corresponding button(as shown below).





Servlet load-on-startup

The value of the tag load-on-startup helps the container determine when the servlet has to be loaded.

A value >=0 means that the servlet has to be loaded when the application is deployed.

If the value is less than zero or if the tag element is not present, the servlet will be loaded when it is first called.

Also, the order in which servlets are loaded is determined by the value of load-on-startup. The servlet which has a lower load-on-startup value will be loaded first. e.g the servlet with value 2 will be loaded before the servlet with this value as 4.

Apart from this, if two servlets have same value of load-on-startup, then they are loaded in the order in which they are defined in the Deployment descriptor file.

January 4, 2011

An Unusual Paragraph

This is a most unusual paragraph. How quickly can you find out
what is so unusual about it? It looks so ordinary, you'd think
nothing was wrong with it and in fact, nothing is wrong with it.
It is unusual, why? Study it. Think about it and you may find
out. If you work at it for a bit,
it will dawn on you. Try to do it without coaching.


January 3, 2011

World War - I Puzzle

A grandfather is telling his grandson stories of world war.

He said :

"At the end of World War 1, I was awarded for my bravery
after saving a group of my men"

"We were fighting in northern France and one of our
enemies threw a grenade at us. I managed to pick it up and
throw it away before it exploded. So right after the war
ended, a General gave me a sword, engraved with the words
'Awarded for Bravery and Valor, A True Hero, World War 1'".

"The grandson thinks about the story for a minute and then
says "Grandpa, that story can't be true!"

How did the grandson know?

December 26, 2010

Program to Shuffle a pack of card in O(n)

public class Shuffle {

public static void shuff(int[] arr) {
for(int i=0; i
int rand  = (int)(Math.random() * arr.length);
int temp = arr[rand];
arr[rand] = arr[i];
arr[i] = temp;
}
for(int i=0; i
System.out.println(" "+arr[i]);
}
}
}

December 23, 2010

MarkIT Telephonic Interview Questions

1. Difference between ArrayList and LinkedList. Why search in ArrayList is faster than in LL. When to use what

Ans : Array List is implemented as an Array and since arrayList is indexed, we just need to go to array+i th position directly. We do not have to traverse the whole list as in case of LL

2. HashCode and Equals contract

3. Difference between HashTable and HashMap
(If have inserted lakhs of objects in a HashTable and these threads simultaneously want to access a method(lets say equals() method)... one thread will accquire lock on the method, so others will have to wait. This will be a performance hit.
This is the reason why HashMap (not synchronised) came into picture. HashTable is legacy datastructure.

4. Difference between IOC and Dependency Injection

5. Difference between Error and Exception. Are all Errors Irrecoverable. (Think about NoClassDefFoundError)

December 8, 2010

java.lang.ThreadDeath

java.lang.Object
          |
java.lang.Throwable
          |
java.lang.Error
          |
java.lang.ThreadDeath (implements Serializable interface)

This Error is thrown by the Thread when the stop method with zero arguments is called.