Navigating the API

The packages that make up the core of the Java environment and the interfaces, classes, and exceptions they contain are fully documented in what is known as "The Java API"

If you have never programmed in an object-oriented language like Java, what you see in the API probably won't make a whole lot of sense just yet. That's ok -- it will later on. For now, just click on the link above and familiarize yourself with its layout.

As you will discover, the API is a big document. Most programmers don't have to deal with all it has to offer -- and there is no sense in trying to memorize its contents. However, to program in Java, you do need to know how to navigate through it. To test your ability to find what you are looking for in the API, try finding the answers to the following questions:

Test Your API Navigation Skills...
  1. In the java.util.Scanner class, the three methods named "hasNext" return something of type boolean. The method named "nextLine" in the same class returns something of what type?

  2. The Scanner class "extends" the Object class, as can be seen in the API (towards the top of the page on the Scanner class). As such, it will inherit all the methods of the Object class, in addition to those unique to the Scanner class. Click on the link to the Object class to learn more about this "parent" class. Then, name eight of the methods of the java.util.Scanner class that begin with an "n" that are not inherited from the class java.lang.Object, and then name two that are.

  3. What method of the java.lang.Math class will return the value of its first argument raised to the power of its second argument? What type are the arguments to this method?

  4. Name the three fields of the java.lang.System class.

  5. How many constructors does the java.io.FileInputStream class have?

  6. The class javax.swing.JButton is an immediate subclass of what other class? (Hint: javax.swing.JComponent is an immediate subclass of java.awt.Container))

  7. How many classes are listed as associated with the java.lang package? (Technically, some of the elements in the list shown are "interfaces", but for now we won't worry about that distinction.)

  8. To what package does the Ellipse2D class belong? (Hint: the package name containing the class Object is java.lang)