Exercises

Bruce Eckel’s Thinking in Java Contents | Prev | Next

  1. Create
    two classes,
    A
    and
    B,
    with default constructors (empty argument lists) that announce themselves.
    Inherit a new class called
    C
    from
    A,
    and create a member
    B
    inside
    C.
    Do not create a constructor for
    C.
    Create an object of class
    C
    and observe the results.
  2. Modify
    Exercise 1 so that
    A
    and
    B
    have constructors with arguments instead of default constructors. Write a
    constructor for
    C
    and perform all initialization within
    C’s
    constructor.
  3. Take
    the file
    Cartoon.java
    and comment out the constructor for the
    Cartoon
    class. Explain what happens.
  4. Take
    the file
    Chess.java
    and comment out the constructor for the
    Chess
    class. Explain what happens.
3

More by Author

Must Read