SJSU/Udacity CS046

Problem Set 9

  1. Interfaces
  2. Comparable Circle
  3. Cast
  4. Smallest
  5. Inheritance
  6. Manager 1
  7. Manager 2
  8. Geometric Solid
  9. True False Question

Interfaces

We want to define an interface, Growable. Many things are Growable: from tomatoes to babies. Fill in the blank in the given header to complete it.
public _______________ Growable
{
      //....
}
interface
We want to declare an interface Readable. It has one method read that takes no parameters and returns nothing. Complete the code below by speciying the method that all implementing classes need to provide. Don't use any unnecessary keywords.
public interface Readable
{
   _______________________
}
void read();
A class Dog wishes to implement the Growable interface. Complete the class header to do that. Other actions are also required, but you just need to complete the header.
public class Dog _____________________________________
implements Growable
The class Billboard imlements the Readable interface. It has one method, read which takes no parameters and returns no value. Billboard may contain many methods, but there is one method that is required. Provide the header for that method
public class Billboard
{
   _____________________   //What goes here?
   {
      // ...
   }
   // ...
}
public void read()
What is the name of the method that a class must provide if the class implements the Comparable interface from the standard Java library? If yo do not remember, you can always look it up in the API documentation. compareTo

The String and Integer classes both implement the Comparable interface. For each of the following statements mark if it is valid or invalid.

  1. Valid|Invalid Comparable c1 = "Hello";
  2. Valid|Invalid Comparable c2 = new Integer(42)
  3. Valid|Invalid Comparable c3 = new Comparable();
  4. Valid|Invalid String s = c1;

Problem on this page?

Your name:

Your email address:

Problem description:

To protect against spam robots, please answer this simple math problem:
× =