2. In a try/catch/finally statement, you may have 0 or more "catch" clauses, and 0 or 1 finally statements.
This gives a sensible way to catch a number of different kinds of errors within one code block (several catches)
3. Methods (but not constructors, obviously) in derived classes must have the same return type as the method in the parent class.
For example, for the following abstract class:
public abstract class Stak { public Stak () {}; public abtract Stak pop(); public abstract Object top(); }You could have the following derived class:
public class MyStak { public MyStak () {super();}; public Stak pop() (return (this);}; public Object top() {return(new Integer(7));}; }Frankly, I do not understand why this is like this. I was unable to find this rule clearly stated anywhere in the book (or "The Java Programming Language", or "Core Java"), nor can I think of a good reason why you can return a derived object, but not have a derived return specification. But that's the way it is! Code accordingly.
4. It seems that Vector does slide stuff around for you. You might try running the following code to check it out:
import java.util.*; public class VecTest extends Vector { public VecTest () { super(); } public static void main(String argv[]) { VecTest v = new VecTest(); System.out.println(v.size()+"is the size of the Vector"); v.insertElementAt(new Integer(3),0); System.out.println(v+" is now the contents--just inserted 3 at 0 and "+v.size()+" is the size"); v.insertElementAt(new Integer(4),0); System.out.println(v+" is now the contents--just inserted 4 at 0 and "+v.size()+" is the size"); v.insertElementAt(new Integer(5),1); System.out.println(v+" is now the contents--just insterted 5 at 1 and "+v.size()+" is the size"); v.removeElementAt(1); System.out.println(v+" is now the contents--just removed from space 1 and "+v.size()+" is the size"); } }