Thinking in Java Fourth Edition Bruce Eckel Chapter 6 Exercise 22

Exercise 22: Create a final class and attempt to inherit from it.

class SmallBrain
{
}

final class Dinosaur
{
    SmallBrain x = new SmallBrain();
}

// class Further extends Dinosaur {} // error: cannot inherit from final Dinosaur

public class JurassicEx
{
    public static void main(String[] args)
    {
        Dinosaur d = new Dinosaur();
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *