By Ramakrishna on Aug 17, 2010 in Java Interview Questions | 0 Comments
Hashtable Hashtable is basically a datastructure to retain values of key-value pair. It didn’t allow null for both key and value. You will get NullPointerException if you add null value. It is synchronized. So it come with its cost. Only one thread can access in one time Hashtable<Interger,String>; cityTable=new Hashtable<Interger,String>(); cityTable.put(1,”Lahore”); cityTable.put(2,”Karachi”); cityTable.put(3,null); // NullPointerException [...]
By Ramakrishna on Apr 6, 2009 in Java Interview Questions | 2 Comments
Q) What is the difference between ‘throw’ and ‘throws’ ?And it’s application? Rep) Exceptions that are thrown by java runtime systems can be handled by Try and catch blocks. With throw exception we can handle the exceptions thrown by the program itself. If a method is capable of causing an exception that it does not [...]
By Ramakrishna on Apr 5, 2009 in Java Interview Questions | 0 Comments
import java.util.Calendar.*; import java.lang.*; //its’ a default package which will import class LeapYear { public static void main(String args[])throws Exception { Calendar cal=Calendar.getInstance(); int year=cal.get(Calendar.YEAR); if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) { System.out.println(“Leap Year”); }else { System.out.println(“Not a Leap Year); } } } // [...]
By Ramakrishna on Apr 4, 2009 in Define creating and extracting of jar | 0 Comments
Q) What is EAR file Rep) Enterprise Archive file. A JAR archive that contains a J2EE application. Q) What is JAR file Rep) Java Archive file it contains a J2EE application. You can create a JAR file using the command jar cf XYZ.jar *.class *.gif if will compress all the .class files and the related [...]