A single file contains the following Java code (exactly as it appears here, there is nothing else in the file). The file is compiled by the Java compiler and the resulting Java program is run.
class Foo { public static void println() { System.out.println("Foo"); } } public class FooDemo { public static void main(String[] argv) { System.out.println("FooDemo"); Foo.println(); } }
FooDemo Foo
A single file contains the following Java code (exactly as it appears here, there is nothing else in the file). The file is compiled by the Java compiler and the resulting Java program is run.
public class Loop { public static void main(String[] argv) { String a[] = new String[4]; a[0] = "Alpha"; a[1] = "Beta"; a[2] = "Delta"; a[3] = "Gamma"; // init for (int i = 0; i < 4; i++) { System.out.println((i+1) + ". " + a[i]); } } }
What output does the program produce?
1. Alpha 2. Beta 3. Delta 4. Gamma
This program is compiled and run
class Thing { int x; public Thing(int i) { x = i; } public void speak() { System.out.print(x); } } public class ThingDemo { public static void main(String[] argv) { Thing a, b; a = new Thing(1); b = a; System.out.print("a "); a.speak(); System.out.print(" b "); b.speak(); System.out.println(); b.x = 2; System.out.print("a "); a.speak(); System.out.print(" b "); b.speak(); System.out.println(); } }
What output does this program produce?
a 1 b 1 a 2 b 2
Answer the following questions accurately but briefly. There is a correct one word answer to each question.