1. Suppose i have a TreeSet<MyObject>, does MyObject must implement Comparable? What happens when i try to retireve them?
2. In questions regarding ordering, unless specified otherwise, when the exam say ordered elements mean in "ascending order"?
3. Do both, java and javac commands ignore the options when stated after the .java or .class respectively? like specifing the -D option at last.
4. StringBuilder doesnt overload equals and hashcode directly form Object? I mean, why String does and Stringbuilder doesnt since it is a predefined Java class.
5. Does the following statement is true? In some places i see its true some others i read its false.
"If the GC decides to delete an object, and if finalize() has never been invoked for that object, it is guaranteed that the GC will invoke finalize() for that object before the object "
Constructs a new, empty tree set, sorted according to the natural ordering of its elements. All elements inserted into the set must implement the Comparable interface.
I tried it out and when you try to add a second element of type MyObject to the TreeSet then you will get an exception if MyObject does not implement Comparable. It will compile but
then throw the exception. If you just put one element into the TreeSet then everything is fine as no ordering has to be done.