【文章內(nèi)容簡介】
tX() { return x。 }}public class Gamma { static Foo fooBar(Foo foo) { foo = new Foo(100)。 return foo。 } public static void main(String[] args) { Foo foo = new Foo(300)。 (() + )。 Foo fooFoo = fooBar(foo)。 (() + )。 (() + )。 foo = fooBar(fooFoo)。 (() + )。 (())。 }} 15. 下列代碼運(yùn)行的結(jié)果是:public class Base { public static final String FOO = foo。16. class Sub extends Base { public static final String FOO = bar。} public static void main(String[] args) { Base b = new Base()。 Sub s = new Sub()。 ()。 ()。 ()。 ()。 (((Base) s).FOO)。 }}A. foofoofoofoofoo 16. 關(guān)于下列代碼說法正確的是:public class ItemTest { private final int id。 public ItemTest(int id) { = id。 } public void updateId(int newId) { id = newId。 } public static void main(String[] args) { ItemTest fa = new ItemTest(42)。 (69)。 ()。 }}A. 編譯錯誤,fa對象屬性id的值沒有改變,應(yīng)然是42,fa對象屬性id的值改變成新的值6917. 請看下列代碼編譯和運(yùn)行的結(jié)果是:public class Student { private String name=sun。 public static void main(String[] args) { Student[] students=new Student[2]。 (students[0].name)。 ()。 }}A. sun 2 2 118. 下列代碼的輸出結(jié)果是:abstract class Vehicle { public int speed() { return 0。 }}class Car extends Vehicle { public int speed() { return 60。 }}class RaceCar extends Car { public int speed() { return 150。 }}public class TestCar { public static void main(String[] args) { RaceCar racer = new RaceCar()。 Car car = new RaceCar()。 Vehicle vehicle = new RaceCar()