Que: What is difference between final, finally and finalize ?
Ans: final: final is a keyword, final can be a variable, method or class.You,can't change the value of final variable, can't override final method and can't inherit final class.
finally: finally block is used in exception handling. finally block is always executed either exception occured or not. finalize():finalize() method is used in garbage collection.finalize() method is invoked just before the object is garbage collected. The finalize() method can be used to perform any cleanup processing.
Que: What is Garbage Collection ?
Ans: Garbage collection is a process of unreferencing the runtime unused(idle) objects.It is performed for memory management.It removed the unused objects and free the memory area.
Que: What kind of thread is the Garbage collector thread ?
Ans: Daemon thread.
Que: What is the purpose of finalize() method ?
Ans: finalize() method is called just before the object is going to garbage collected.It is used to perform memory cleanup process.
Que: What is gc() method ?
Ans: gc() method is a daemon thread. gc() method is defined in System class and Runtime Class that is used to send request to JVM to perform garbage collection.
Que: What is the use of the Runtime class ?
Ans: Runtime class is used to provide access to the Java runtime system.
Que: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class ?
Ans: The Reader/Writer class is used to read or write character-oriented data and InputStream/OutputStream class is used to read or write byte-oriented data.
Que: What is Serialization ?
Ans: Serialization is a process of writing the state of an object(class objects ) into a byte stream(means in a file system).It is mainly used to travel object's state on the network.It is mainly used to write objects state in file system(txt or any).
Que: What is Deserialization ?
Ans: Deserialization is the process of reconstructing the object from the serialized state object .It is the reverse operation of serialization process.
Que: What is transient keyword ?
Ans: If you make any data member as transient type ,you can not serialized that data member in file while Serialization.
Que: What is Externalizable ?
Ans: Externalizable is an interface is used to write the state of an object into a byte stream in compressed format.It is not a marker interface.
Que: What is the difference between Serializalble and Externalizable interface ?
Ans: Serializable is a marker interface but Externalizable is not a marker interface.When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() two methods to control more complex object serailization process. When you use Externalizable interface, you have a complete control over your class's serialization process.
Que: What is reflection ?
Ans: Reflection is the process of examining or modifying the runtime behaviour of a class at runtime.It is used in: IDE tools (Integreted Development Environment) e.g. Eclipse, MyEclipse, NetBeans,Jdeveloper, Debugger, Test Tools etc.
Que: What is difference between ArrayList and Vector ?
Ans: ArrayList Vector
1) ArrayList is not synchronized. Vector is synchronized.
2) ArrayList is not a legacy class. Vector is a legacy class.
3) ArrayList increases its size by 50% Vector increases its size by doubling the initial
of the initial array size. array size
Que: What is difference between ArrayList and LinkedList ?
Ans: ArrayList LinkedList
1) ArrayList uses a dynamic array. LinkedList uses doubly linked list.
2) ArrayList is not efficient for manipulation LinkedList is efficient for
because a lot of shifting is required. manipulation.(i.e.insertion,deletion)
Que: What is difference between HashMap and Hashtable ?
Ans: HasMap Hastable
1)HashMap is not synchronized. Hashtable is synchronized.
2)HashMap can contain one null Hashtable cannot contain any null key
key and multiple null values. nor value.
Que: What is difference between HashSet and HashMap ?
Ans: HashSet contains only values whereas HashMap contains entry(key,value) pair.
Que: What is difference between TreeSet and HashSet ?
Ans: TreeSet maintains ascending order whereas HashSet maintains no order.
Que: What is difference between Set and List ?
Ans: Set contains only unique elements whereas List can contain duplicate elements.
Que: What is difference between HashMap and TreeMap ?
Ans: HasMap can contain one null key whereas TreeMap can not contain any null key.
and HasMap maintain order whereas TreeMap maintain ascending order.
Que: What is difference between Iterator and ListIterator ?
Ans: Iterator traverses the elements in forward direction only whereas ListIterator traverses the elements in forward and backward direction.Both are defined under util package.
Que: Can you make List,Set and Map elements synchronized ?
Ans: Yes, Collections class provides methods to make List,Set or Map elements to synchronized:
public static List synchronizedList(List l){ }
public static Set synchronizedSet(Set s){ }
public static SortedSet synchronizedSortedSet(SortedSet s){ }
public static Map synchronizedMap(Map m){ }
public static SortedMap synchronizedSortedMap(SortedMap m){ }
Que: What is difference between Iterator and Enumeration ?
Ans: Iterator can traverse legacy and non-legacy elements both whereas Enumeration can traverse only legacy elements.
Que: What is legacy elements in java ?
Ans: Before Collection Framework, defined several classes and interface that provide method for storing objects. When Collection framework were added in J2SE 1.2, the original classes were reengineered(included) to support the collection interface.
These classes are also known as Legacy classes. All legacy claases and interface were redesign by JDK 5 to support Generics.
Que: What is the Dictionary class ?
Ans: The Dictionary class provides the capability to store key-value pairs.
Que: What is difference between Comparable and Comparator interface ?
Ans: Comparable Comparator
1)Comparable provides only one sort of Comparator provides multiple sort of
sequence. sequences.
2)It provides one method named compareTo(). It provides one method named compare().
3)It is found in java.lang package. It is found in java.util package.
4)Actual class is modified. Actual class is not modified.
Ans: final: final is a keyword, final can be a variable, method or class.You,can't change the value of final variable, can't override final method and can't inherit final class.
finally: finally block is used in exception handling. finally block is always executed either exception occured or not. finalize():finalize() method is used in garbage collection.finalize() method is invoked just before the object is garbage collected. The finalize() method can be used to perform any cleanup processing.
Que: What is Garbage Collection ?
Ans: Garbage collection is a process of unreferencing the runtime unused(idle) objects.It is performed for memory management.It removed the unused objects and free the memory area.
Que: What kind of thread is the Garbage collector thread ?
Ans: Daemon thread.
Que: What is the purpose of finalize() method ?
Ans: finalize() method is called just before the object is going to garbage collected.It is used to perform memory cleanup process.
Que: What is gc() method ?
Ans: gc() method is a daemon thread. gc() method is defined in System class and Runtime Class that is used to send request to JVM to perform garbage collection.
Que: What is the use of the Runtime class ?
Ans: Runtime class is used to provide access to the Java runtime system.
Que: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class ?
Ans: The Reader/Writer class is used to read or write character-oriented data and InputStream/OutputStream class is used to read or write byte-oriented data.
Que: What is Serialization ?
Ans: Serialization is a process of writing the state of an object(class objects ) into a byte stream(means in a file system).It is mainly used to travel object's state on the network.It is mainly used to write objects state in file system(txt or any).
Que: What is Deserialization ?
Ans: Deserialization is the process of reconstructing the object from the serialized state object .It is the reverse operation of serialization process.
Que: What is transient keyword ?
Ans: If you make any data member as transient type ,you can not serialized that data member in file while Serialization.
Que: What is Externalizable ?
Ans: Externalizable is an interface is used to write the state of an object into a byte stream in compressed format.It is not a marker interface.
Que: What is the difference between Serializalble and Externalizable interface ?
Ans: Serializable is a marker interface but Externalizable is not a marker interface.When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() two methods to control more complex object serailization process. When you use Externalizable interface, you have a complete control over your class's serialization process.
Que: What is reflection ?
Ans: Reflection is the process of examining or modifying the runtime behaviour of a class at runtime.It is used in: IDE tools (Integreted Development Environment) e.g. Eclipse, MyEclipse, NetBeans,Jdeveloper, Debugger, Test Tools etc.
Que: What is difference between ArrayList and Vector ?
Ans: ArrayList Vector
1) ArrayList is not synchronized. Vector is synchronized.
2) ArrayList is not a legacy class. Vector is a legacy class.
3) ArrayList increases its size by 50% Vector increases its size by doubling the initial
of the initial array size. array size
Que: What is difference between ArrayList and LinkedList ?
Ans: ArrayList LinkedList
1) ArrayList uses a dynamic array. LinkedList uses doubly linked list.
2) ArrayList is not efficient for manipulation LinkedList is efficient for
because a lot of shifting is required. manipulation.(i.e.insertion,deletion)
Que: What is difference between HashMap and Hashtable ?
Ans: HasMap Hastable
1)HashMap is not synchronized. Hashtable is synchronized.
2)HashMap can contain one null Hashtable cannot contain any null key
key and multiple null values. nor value.
Que: What is difference between HashSet and HashMap ?
Ans: HashSet contains only values whereas HashMap contains entry(key,value) pair.
Que: What is difference between TreeSet and HashSet ?
Ans: TreeSet maintains ascending order whereas HashSet maintains no order.
Que: What is difference between Set and List ?
Ans: Set contains only unique elements whereas List can contain duplicate elements.
Que: What is difference between HashMap and TreeMap ?
Ans: HasMap can contain one null key whereas TreeMap can not contain any null key.
and HasMap maintain order whereas TreeMap maintain ascending order.
Que: What is difference between Iterator and ListIterator ?
Ans: Iterator traverses the elements in forward direction only whereas ListIterator traverses the elements in forward and backward direction.Both are defined under util package.
Que: Can you make List,Set and Map elements synchronized ?
Ans: Yes, Collections class provides methods to make List,Set or Map elements to synchronized:
public static List synchronizedList(List l){ }
public static Set synchronizedSet(Set s){ }
public static SortedSet synchronizedSortedSet(SortedSet s){ }
public static Map synchronizedMap(Map m){ }
public static SortedMap synchronizedSortedMap(SortedMap m){ }
Que: What is difference between Iterator and Enumeration ?
Ans: Iterator can traverse legacy and non-legacy elements both whereas Enumeration can traverse only legacy elements.
Que: What is legacy elements in java ?
Ans: Before Collection Framework, defined several classes and interface that provide method for storing objects. When Collection framework were added in J2SE 1.2, the original classes were reengineered(included) to support the collection interface.
These classes are also known as Legacy classes. All legacy claases and interface were redesign by JDK 5 to support Generics.
Que: What is the Dictionary class ?
Ans: The Dictionary class provides the capability to store key-value pairs.
Que: What is difference between Comparable and Comparator interface ?
Ans: Comparable Comparator
1)Comparable provides only one sort of Comparator provides multiple sort of
sequence. sequences.
2)It provides one method named compareTo(). It provides one method named compare().
3)It is found in java.lang package. It is found in java.util package.
4)Actual class is modified. Actual class is not modified.
No comments:
Post a Comment