interface Program { void entryPoint(String... args); } abstract class AbstractProgram implements Program { protected AbstractProgram(String[] args) { this.entryPoint(args); } } // MISSING CLASS: FirstProgram
class SecondProgram extends FirstProgram { public SecondProgram(String[] args) { super(args); } public void entryPoint(String... args) { // MISSING CODE
super.entryPoint("Number " + ++i + ": ", s1, s2); } } class Main { public static void program(String... args) { new FirstProgram(args); new SecondProgram(args); } } /** ProgressiveProgram should print: * KEEP PORTLAND WEIRD! * Number 1: KEEP KEEP Number 2: KEEP PORTLAND Number 3: KEEP WEIRD! * Number 4: PORTLAND KEEP Number 5: PORTLAND PORTLAND Number 6: PORTLAND WEIRD! * Number 7: WEIRD! * KEEP Number 8: WEIRD! * PORTLAND Number 9: WEIRD! * WEIRD! */ public class ProgressiveProgram { public static void main(String args[]) { Main.program("KEEP ", "PORTLAND ", "WEIRD!\n"); } }
Programming Exercises
- Compose FirstProgram (the missing class).
- Supply the code that is missing from SecondProgram.entryPoint. Use exactly three semicolons.
Questions
- What is the order of growth of the running time of FirstProgram.entryPoint as a function of its inputs?
- What is the order of growth of the running time of SecondProgram.entryPoint as a function of its inputs?
Your choices are:
- constant
- logarithmic
- linear
- linearithmic
- quadradic
- cubic
- exponential
- conservative
- liberal
- progressive
- weird