Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎notes‎ > ‎

2017-11-21

posted Nov 22, 2017, 6:19 AM by Konstantinovich Samuel   [ updated Nov 22, 2017, 9:20 AM ]
Goal : More Interfaces
 
   From Yesterday:
-An interface declaration can contain method signatures + static methods and constants
-The only methods that have implementations are static methods. 
-IGNORE default methods, you do not need to touch them or implement them. We are NOT learning about them.
-A class that implements an interface must implement all the methods declared in the interface. 
-An interface name can be used anywhere a type can be used

1. What is wrong with the following interface?

public interface SomethingIsWrong {
    void aMethod(int aValue){
        System.out.println("Hi Mom");
    }
}

2. Is the following interface valid?
public interface Marker {
}

3. What methods would a class that implements the java.lang.CharSequence interface have to implement?

Try this:
4. Write a class that implements the CharSequence interface found in the java.lang package. Your implementation should return the string backwards. 
5. Write a small main method to test your class; make sure to call all four methods.



Comments