单选题1. class SuperClass { 2. public a geta() { 3. return new a(); 4. } 5. } 6. class SubClass extends SuperClass { 7. public b geta() { 8. return new b(); 9. } 10. } Which is true?()A Compilation will succeed if a extends b.B Compilation will succeed if b extends a.C Compilation will always fail because of an error in line 7.D Compilation will always fail because of an error in line 8.
单选题
1. class SuperClass { 2. public a geta() { 3. return new a(); 4. } 5. } 6. class SubClass extends SuperClass { 7. public b geta() { 8. return new b(); 9. } 10. } Which is true?()
A
Compilation will succeed if a extends b.
B
Compilation will succeed if b extends a.
C
Compilation will always fail because of an error in line 7.
D
Compilation will always fail because of an error in line 8.
参考解析
解析:
暂无解析
相关考题:
多选题import java.awt*; public class X extends Frame ( public static void main(string args) ( X x = new X (); X.pack(); x.setVisible(true); ) public X () ( setlayout (new GridLayout (2,2)); Panel p1 = new panel(); Add(p1); Button b1= new Button (“One”); P1.add(b1); Panel p2 = new panel(); Add(p2); Button b2= new Button (“Two”); P2.add(b2); Button b3= new Button (“Three”); add(b3); Button b4= new Button (“Four”); add(b4); ) ) Which two statements are true? ()AAll the buttons change height if the frame height is resized.BAll the buttons change width if the Frame width is resized.CThe size of the button labeled “One” is constant even if the Frame is resized.DBoth width and height of the button labeled “Three” might change if the Frame is resized.
单选题11. static classA { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println(”B “); } 16. } 17. public static void main(String[] args) { 18.A a=new B(); 19. a.process(); 20.} What is the result?()A BB The code runs with no output.C An exception is thrown at runtime.D Compilation fails because of an error in line 15.E Compilation fails because of an error in line 18.F Compilation fails because of an error in line 19.
单选题Which statements concerning the switch construct are true?()AAll switch statements must have a default label.BThere must be exactly one label for each code segment in a switch statement.CThe keyword continue can never occur within the body of a switch statement.DNo case label may follow a default label within a single switch statement.EA character literal can be used as a value for a case label.
多选题public class Parent { int change() {…} } class Child extends Parent { } Which methods can be added into class Child?()Apublic int change(){}Bint chang(int i){}Cprivate int change(){}Dabstract int chang(){}
单选题public class test ( public static void main (String args) { int i = 0xFFFFFFF1; int j = ~i; } ) What is the decimal value of j at line 5?()A 0B 1C 14D –15E An error at line 3 causes compilation to fail.F An error at line 4 causes compilation to fail.
单选题class Parent { String one, two; public Parent(String a, String b){ one = a; two = b; } public void print(){ System.out.println(one); } } public class Child extends Parent { public Child(String a, String b){ super(a,b); } public void print(){ System.out.println(one + " to " + two); } public static void main(String arg[]){ Parent p = new Parent("south", "north"); Parent t = new Child("east", "west"); p.print(); t.print(); } } Which of the following is correct?()A Cause error during compilation. B south east C south to north east to west D south to north east E south east to west
单选题public void test(int x) { int odd = x%2; if (odd) { System.out.println(“odd); } else { System.out.println(“even”); } } Which statement is true?()ACompilation fails.B “odd” will always be output.C “even” will always be output.D “odd” will be output for odd values of x, and “even” for even values.E “even” will be output for add values of x, and “odd” for even values.
单选题public class Test { public static void main(String [] args) { boolean assert = true; if(assert) { System.out.println(”assert is true”); } } } Given: javac -source 1.3 Test.java What is the result?()A Compilation fails.B Compilation succeeds with errors.C Compilation succeeds with warnings.D Compilation succeeds without warnings or errors.
单选题public class Yippee { public static void main(String [] args) { for(int x = 1; x args.length; x++) { System.out.print(args[x] +“ “); } } } and two separate command line invocations: java Yippee java Yippee 1234 What is the result?()A No output is produced. 123B No output is produced. 234C No output is produced. 1234D An exception is thrown at runtime. 123E An exception is thrown at runtime. 234F An exception is thrown at rijntime. 1234
多选题public class ConstOver { public ConstOver (int x, int y, int z) { } } Which two overload the ConstOver constructor? ()AConstOver(){}BProtected int ConstOver (){}CPrivate ConstOver (int z, int y, byte x) {}DPublic Object ConstOver (int x, int y, int z) {}EPublic void ConstOver (byte x, byte y, byte z){}
单选题int x = 3; int y = 1; if (x = y) { System.out.println(“x = “ + x); } What is the result? ()Ax=1Bx=3CCompilationensp;fails.DTheensp;codeensp;runsensp;withensp;noensp;output.ensp;EAnensp;exceptionensp;isensp;thrownensp;atensp;runtime.