practice-Interface - Output Practice Interface Classes Last...

This preview shows page 1 - 2 out of 3 pages.

OutputPractice Interface & ClassesLast Name ______________________ First__________________ Date: 9/15/081. Given MyInterfaceand two classes that implement it, write the output generated by the program in the TestOneAndTwoclass.// In file MyInterface.javapublic interface MyInterface{public String mystery( );}// In file One.javapublic class One implements MyInterface{private String id;public One( String ID ){id = ID;}public String mystery( ){return "> " + id + " <";}}// In file Two.javapublic class Two implements MyInterface{public String mystery( ){return "different";}}// In file TestOneAndTwo.javapublic class TestOneAndTwo{public static void main( String[] args ){MyInterface one = new One( "Kim" );MyInterface anotherOne = new One( "Devon" );MyInterface two = new Two( );System.out.println( one.mystery( ) );System.out.println( anotherOne.mystery( ) );System.out.println( two.mystery( ) );}}

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture