BasicJavaConcept

1. How to copy java object, Java Object is by reference, for example

JavaType a = new JavaType();

JavaType b = a;

If data in a is changed, will it affect b? yes

unless b is a clone of a or b is a new instance which copy a , therefore , a copy method must be implemented in JavaType.

For detail, see http://stackoverflow.com/questions/869033/how-do-i-copy-an-object-in-java

2. HashMap vs. Hashtable

HashMap permits null value, is unsynchronized

Hashtable is synchronized.

both doesnot permit the ordering of inserted elements.

LinkedHashMap can preserve ordering.

3. Hashtable vs. BinaryTree

Hashtable is used for searching an object based on key. Binary Tree is used for sorting and comparing the order based on key.

4. Which datastructure can be used to set the object in the list

LinkedList.set(index, Object);

5. Final class vs. final method

final class can't be subclassed, such as String.

final method can't be overwritten in subclass. Overloading is to define same functions in different implementation with different arguments.

finalize() method is to be implemented in usr object to release resource, this method is called by gabage collection when JVM determines no other refences to the object.

6. Heap vs. stack

7. How to remove a element from a list in a while loop?

get listIternator of the collection object in each loop, then get the object and call remove.

8. == vs. equals , comparator, compareto etc.

http://leepoint.net/notes-java/data/expressions/22compareobjects.html

9. what is polymophic and how is it achieved?

polymophic is the association between the generialized reference and a more specific object

for example, in java,

Employee a = new Person();

or

Manager b = new User();

or

AvpnService c = new Service();

10

How to compare two objects without using sorting algorithm

http://www.javareference.com/jrexamples/viewexample.jsp?id=1l