The java.lang Package. * Math class is defined as final class and its constructor is defined as private that is why you cannot extend and you cannot instantiate Math class. * Math.random() returns a random number between 0.0 and 1.0. * The method Math.ceil(double db) returns a double value the smallest whole number greater than or equals to db. * The method Math.floor(double d) returns a double value the largest whole number less than or equal to db. * In Java Strings are immutable. * You can use either "==" or Object.equals() method to compare two string objects. * The "==" is used to compare whether two references are pointing to same object or not ( call hallow comparison ). * The Object.equals() method compares two string objects character by character ( called deep comparison ). * String objects created with String and StringBuffer class cannot be compared for equality ( returns false ). The java.util Package. * A simple collection places no constraints on type of elements, order of elements , repetition of elements within the collection. * The collection interfaces are Collection, List, Set, and Map. * The java.util.List interface insists ordering and allows duplicates. * The java.util.Set interface eliminates duplicate values and implemented in HashSet and TreeSet classes in collections framework. * If you try to add duplicates in a collection ( Set collection ), the Set.add() method returns false. * In Set interface implementations if null is valid entry , it should appear only one time * The TreeSet class provides ordered set and uses tree for storage. * The TreeMap provides ordered map. * The size of the Vector grows or shrinks depends on the number of elements are getting added or removed. It uses internally array for storage. * A Stack is subclass of Vector that implements a standard last-in, first-out stack. * The Enumeration interface defines the methods by which you can enumerate the elements in a collection of objects. * A BitSet is a really a vector of bits and is used if you want to efficiently store a lot of on-off information. |
9/14/2010
Interview ready notes on java.lang and java.util packages
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment