1、 public class Alpha extends Base public static void main( String args ) new Alpha(); new Base(); Base B: BaseBase C: 编译失败. D: 没有输出. E: 运行时异常.3. 程序的运行结果是?( ) 编译失败. B: hello from a C: hello from bD: hello from b E: hello from ahello from a hello from b4. 运行结果是: class TestSuper TestSuper(int i) class T
2、estSub extends TestSuper class TestAll public static void main (String args) new TestSub(); 编译失败. B: 程序运行没有异常. 第7行抛出异常. D: 第2行抛出异常.5. 程序的运行结果是? 0 B: 1 C: 2 D: 编译失败.6. 对于语句B is a D 和 B has a C,一下哪两种说法是正确的? ( )D是B. B:B是D. C:D是C. D:B是C. E:D继承 B. F:B 继承D.7. 运行结果是? 1 B: 2 C: 第8行编译失败. D: 第14行编译失败.8. 分析: p
3、ublic class ConstOver public ConstOver(int x, int y, int z) 哪两个是对ConstOver 的构造方法的重载? ( )ConstOver() B:protected int ConstOver() private ConstOver(int z, int y, byte x) public Object ConstOver(int x, int y, int z) E:public void ConstOver(byte x, byte y, byte z) 9. 运行结果是? 4,4 B: 4,5 C: 5,4 D: 5,5 E:10
4、. 分析: public class X public X aMethod() return this;1) public class Y extends X 2) 3) 在第2行可以插入哪两项?public void aMethod() B:private void aMethod() public void aMethod(String s) D:private Y aMethod() return null;public X aMethod() return new Y();11. 运行结果是?12. 以下哪两个重载了方法setVar()? ( ) public class Method
5、Over public void setVar(int a, int b, float c) private void setVar(int a, float c, int b) B:public int setVar(int a, float c, int b) return a;protected void setVar(int a, int b, float c) D:public int setVar(int a, int b, float c) return a;protected float setVar(int a, int b, float c) return c;13. 分析
6、:1) class BaseClass 2) private float x = 1.0f;3) protected void setVar(float f) x = f;4) 5) class SubClass extends BaseClass 6) private float x = 2.0f;7) / insert code here 8) 在第7行插入哪两个覆盖了方法setVar()?void setVar(float f) x = f; B:public void setVar(int f) x = f;public void setVar(float f) x = f; D:pu
7、blic double setVar(float f) return f;public final void setVar(float f) x = f; F:protected float setVar() x = 3.0f; return 3.0f;14. 运行结果是? 2 C: 运行时异常. D: 第8行编译错误. E: 第14行编译错误.15. 分析: protected int method1(int a, int b) return 0;在A的子类中,以下哪两个方法是合法的?public int method1(int a, int b) return 0; B:private i
8、nt method1(int a, long b) return 0;private int method1(int a, int b) return 0; D:public short method1(int a, int b) return 0;static protected int method1(int a, int b) return 0;16. 分析:1) public abstract class Test 2) public abstract void methodA();3) 4) public abstract void methodB()5) 6) System.out
9、.println(Hello7) 8) 哪两种改法,可以使程序通过编译?给方法methodA()加方法体 C:在Test的声明中去掉abstractB:用;替换第5-7行 D:在方法methodA()的声明中去掉abstract 在方法methodB()的声明中去掉abstract17. 运行结果是:1) abstract class AbstractIt 2) abstract float getFloat();4) public class AbstractTest extends AbstractIt 5) private float f1 = 1.0f;6) private float
10、 getFloat() return f1; 编译成功. B: 运行时异常. C: 第2行编译失败. D: 第6行编译失败.18. 在接口中哪两个方法的声明是合法的?void method1(); B:public void method2(); C:static public void method5();protected void method3(); E:final public void method4();19. 分析: 1) public interface Foo 2) int k = 4;哪三项与第2行等价?final int k = 4;public int k = 4;s
11、tatic int k = 4;abstract int k = 4; E:volatile int k = 4; F:protected int k = 4;20. 分析: interface Inter class A implements Inter class B extends A B() A arr = new A10; boolean b1 = this instanceof Inter; boolean b2 = arr instanceof Object; System.out.println(b1 = + b1 + , b2 = + b2);创建B的对象时会输出? b1 =
12、 true, b2 = true C: b1 = true, b2 = false b1 = false, b2 = true E: b1 = false, b2 = false21. 哪一个能通过编译? new Animal().soundOff(); B: Lion l = Alpha1.get(meat eater Elephant e = new Alpha1(); D: new Alpha1().get(veggie).soundOff();22. 分析: class Passenger class Engine interface TransportVehicle void loadPassengers(); interface Helicopter extends TransportVehicle int flyIt( String direction ); abstract class JetStream implements Helicopter 哪种说法是正确的? TransportVehicle ha
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1