practice-Interface

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

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Output Last Name ______________________ First__________________ Date: 9/15/08 1. Given MyInterface and two classes that implement it, write the output generated by the program in the TestOneAndTwo class. // In file MyInterface.java public interface MyInterface { public String mystery( ); } // In file One.java public class One implements MyInterface { private String id; public One( String ID ) { id = ID; } public String mystery( ) { return "> " + id + " <"; } } // In file Two.java public class Two implements MyInterface { public String mystery( ) { return "different"; } } // In file TestOneAndTwo.java public 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( ) ); } }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2. What would be the output of the following program (line for line)? public class MyClass
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/11/2009 for the course CS 205214 taught by Professor Balasooriya/kouvetakis during the Spring '09 term at ASU.

Page1 / 3

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online