Tuesday, December 30, 2008

Which of the following statements are true?

1:Garbage collection is platform dependent
2:You can suggest when garbage collection will run but cannot be certain when it will take place
3:A reference to a primitive variable is eligable for garbage collection when it is set to null
4:The automatic garbage collection of the JVM prevents programs from ever running out of memory

Wednesday, December 24, 2008

TO GET THE MONITOR SIZE

Toolkit toolkit = Toolkit.getDefaultToolkit();

// Get the current screen size
Dimension scrnsize = toolkit.getScreenSize();

System.out.println("height::"+scrnsize.height);
System.out.println("width::"+scrnsize.width);

Monday, December 15, 2008

To generate a random String



Random random = new Random();
long r1 = random.nextLong();
long r2 = random.nextLong();
String hash1 = Long.toHexString(r1);
String hash2 = Long.toHexString(r2);
String hash = hash1 + hash2;