单选题1. class A {  2. public byte getNumber ()  {  3.   return 1;  4.   }  5. }  6.    7. class B extends A {  8. public short getNumber()  {  9.  return 2;  10. }  11.    12. public static void main (String args[]) {   13.    B  b = new B ();  14.      System.out.printIn(b.getNumber())     15.   }  16. }    What is the result?()A Compilation succeeds and 1 is printed.B Compilation succeeds and 2 is printed.C An error at line 8 causes compilation to fail.D An error at line 14 causes compilation to fail.E Compilation succeeds but an exception is thrown at line 14.

单选题
1. class A {  2. public byte getNumber ()  {  3.   return 1;  4.   }  5. }  6.    7. class B extends A {  8. public short getNumber()  {  9.  return 2;  10. }  11.    12. public static void main (String args[]) {   13.    B  b = new B ();  14.      System.out.printIn(b.getNumber())     15.   }  16. }    What is the result?()
A

 Compilation succeeds and 1 is printed.

B

 Compilation succeeds and 2 is printed.

C

 An error at line 8 causes compilation to fail.

D

 An error at line 14 causes compilation to fail.

E

 Compilation succeeds but an exception is thrown at line 14.


参考解析

解析: 暂无解析

相关考题:

class A{public int getNumber(int a){return a+1;}}class B extends A{public int getNumber(int a, char c){return a+2;}public static void main(String[] args){B b=new B();System.out.println(b.getNumber(0));}}what is the result?()A.compilation succeeds and 1 is printedB.compilation succeeds and 2 is printedC.compilation succeeds and 3 is printedD.An error at this program cause compilation to fail

写出程序运行的结果Public class BasePublic virtual string Hello() {return “Base”;}Public class Sub:BasePublic override string Hello() {return “Sub”;}1. Base b = new Base(); b.Hello;2. Sub s = new Sub(); s.Hello;3. Base b = new Sub (); b.Hello;4. Sub s = new Base(); s.Hello;

1. public class ReturnIt {  2. return Type methodA(byte x, double y) {  3. return (long)x / y * 2;  4. }  5. }  What is the narrowest valid returnType for methodA in line2?()  A、 intB、 byteC、 longD、 shortE、 floatF、 double

1. class BaseClass {  2. private float x = 1.of;  3. protected float getVar() { return x; }  4. }  5. class SubClass extends BaseClass {  6. private float x = 2.Of;  7. // insert code here 8. }   Which two are valid examples of method overriding when inserted at line 7?() A、 float getVar() { return x; }B、 public float getVar() { return x; }C、 public double getVar() { return x; }D、 protected float getVar() { return x; }E、 public float getVar(float f) { return f; }

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;

1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() A、 Compilation will succeed for all classes and interfaces.B、 Compilation of class C will fail because of an error in line 2.C、 Compilation of class C will fail because of an error in line 6.D、 Compilation of class AImpl will fail because of an error in line 2.

1. public class A {  2. public void doit() {  3. }  4. public String doit() {  5. return “a”;  6. }  7. public double doit(int x) {  8. return 1.0;  9. }  10.}  What is the result?() A、 An exception is thrown at runtime.B、 Compilation fails because of an error in line 7.C、 Compilation fails because of an error in line 4.D、 Compilation succeeds and no runtime errors with class A occur.

Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. private static void process(byte[] b) { }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?() A、 process(bytes);B、 BitUtils.process(bytes);C、 app.BitUtils.process(bytes);D、 util.BitUtils.process(bytes);E、 import util.BitUtils. *; process(bytes);F、 SomeApp cannot use the process method in BitUtils.

现有:   1. class Synapse {    2.    protected int gap() { return 7; }    3. }   4.     5. class Creb extends Synapse {    6.   // insert code here   7. }    分别插入到第 6 行,哪三行可以编译?()A、 int gap() { return 7; }B、 public int gap() { return 7; }C、 private int gap(int x) { return 7; }D、 protected Creb gap() { return this; }E、 public int gap() { return Integer.getInteger ("42"); }

1. public class returnIt (  2. returnType methodA(byte x, double y) (  3. return (short) x/y * 2;  4. )  5. )   What is the valid returnType for methodA in line 2?()  A、 IntB、 ByteC、 LongD、 ShortE、 FloatF、 Double

Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   Which two overload the ConstOver Constructor?()A、 ConstOver() {}B、 protected int ConstOver(){}C、 private ConstOver(int z, int y, byte x ) {}D、 public Object ConstOver(Int x, int y, int z) {}E、 pubic void ConstOver (byte x, byte y, byte z) {}

1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()  A、 static class InnerOne { public double methoda() { return d1; } }B、 static class InnerOne { static double methoda() { return d1; } }C、 private class InnerOne { public double methoda() { return d1; } }D、 protected class InnerOne { static double methoda() { return d1; } }E、 public abstract class InnerOne { public abstract double methoda(); }

class A {  public byte getNumber() {  return 1;  }  }  class B extends A {  public short getNumber() {  return 2;  }  public static void main(String args[]) {  B b = new B();  System.out.println(b.getNumber()); }  }   What is the result?()A、 1B、 2C、 An exception is thrown at runtime.D、 Compilation fails because of an error in line 8.E、 Compilation fails because of an error in line 14.

1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()  A、  Public float getNum()   {return 4.0f; }B、  Public void getNum ()  { }C、  Public void getNum (double d)   { }D、  Public double getNum (float d) {retrun 4.0f; }

单选题class A {  public byte getNumber() {  return 1;  }  }  class B extends A {  public short getNumber() {  return 2;  }  public static void main(String args[]) {  B b = new B();  System.out.println(b.getNumber()); }  }   What is the result?()A 1B 2C An exception is thrown at runtime.D Compilation fails because of an error in line 8.E Compilation fails because of an error in line 14.

单选题1. public class returnIt (  2. returnType methodA(byte x, double y) (  3. return (short) x/y * 2;  4. )  5. )   What is the valid returnType for methodA in line 2?()A IntB ByteC LongD ShortE FloatF Double

单选题1. class A {  2. public byte getNumber ()  {  3.   return 1;  4.   }  5. }  6.    7. class B extends A {  8. public short getNumber()  {  9.  return 2;  10. }  11.    12. public static void main (String args[]) {   13.    B  b = new B ();  14.      System.out.printIn(b.getNumber())     15.   }  16. }    What is the result?()A Compilation succeeds and 1 is printed.B Compilation succeeds and 2 is printed.C An error at line 8 causes compilation to fail.D An error at line 14 causes compilation to fail.E Compilation succeeds but an exception is thrown at line 14.

单选题Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. public static void process(byte[]) { /* more code here */ }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?()A process(bytes);B BitUtils.process(bytes);C util.BitUtils.process(bytes);D SomeApp cannot use methods in BitUtils.E import util.BitUtils.*; process(bytes);

单选题Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. private static void process(byte[] b) { }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?()A process(bytes);B BitUtils.process(bytes);C app.BitUtils.process(bytes);D util.BitUtils.process(bytes);E import util.BitUtils. *; process(bytes);F SomeApp cannot use the process method in BitUtils.

单选题1. class super {  2. public float getNum() {return 3.0f;}  3. }  4.    5. public class Sub extends Super { 6.   7. }   Which method, placed at line 6, will cause a compiler error?()A  Public float getNum()   {return 4.0f; }B  Public void getNum ()  { }C  Public void getNum (double d)   { }D  Public double getNum (float d) {retrun 4.0f; }

多选题Given:  1.  public class ConstOver {  2.  public constOver(int x, int y, int z) {  3.  }  4.  }   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) {}Epubic void ConstOver (byte x, byte y, byte z) {}

单选题class A {   public byte getNumber () {   return 1;   }   }   class B extends A {   public short getNumber() {   return 2;   }    public static void main (String args) {   B b = new B ();    System.out.printIn(b.getNumber())  }   }   What is the result?()A Compilation succeeds and 1 is printed.B Compilation succeeds and 2 is printed.C An error at line 8 causes compilation to fail.D An error at line 14 causes compilation to fail.E Compilation succeeds but an exception is thrown at line 14.

单选题1. class Super {  2. public float getNum() { return 3.0f; }  3. }  4.   5. public class Sub extends Super {  6.   7. }  Which method, placed at line6, causes compilation to fail?()A public void getNum(){}B public void getNum(double d){}C public float getNum() { return 4.0f; }D public double getNum(float d) { return 4.0d; }

单选题class A {   public int getNumber(int a) {   return a + 1;   }   }    class B extends A {   public int getNumber (int a) {   return a + 2   }    public static void main (String args) {   A a = new B();   System.out.printIn(a.getNumber(0));   }   }   What is the result? ()A Compilation succeeds and 1 is printed.B Compilation succeeds and 2 is printed.C An error at line 8 causes compilation to fail.D An error at line 13 causes compilation to fail.E An error at line 14 causes compilation to fail.

单选题1. class A {  2. public byte file Number ( ) { 3. return l;  4. }  5. }  6.  7. Class B extends A {  8. public short getNumber( ) {  9.  return 2;  10. }  11.  12. public short getNumber( ) {  13. B b = new B( );  14. System.out.printIn(b.getNumber( ));  15. }  16. }   What is the result()?A Compilation succeeds and l is printed.B Compilation succeeds and 2 printed.C An error at line 8 cause compilation to fail.D An error at line 14 cause complication to fail.E Complication succeeds but an exception is thrown at line 14.

单选题1. class A {  2. public int getNumber(int a) {  3.     return a + 1;  4. }  5. }  6.    7. class B extends A {  8. public int getNumber (int a) {  9. return a + 2  10. }  11.    12. public static void main (String args[])  {  13. A a = new B();  14. System.out.printIn(a.getNumber(0));  15.    } 16. }     What is the result?()A Compilation succeeds and 1 is printed.B Compilation succeeds and 2 is printed.C An error at line 8 causes compilation to fail.D An error at line 13 causes compilation to fail.E An error at line 14 causes compilation to fail.

多选题1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()Astatic class InnerOne { public double methoda() { return d1; } }Bstatic class InnerOne { static double methoda() { return d1; } }Cprivate class InnerOne { public double methoda() { return d1; } }Dprotected class InnerOne { static double methoda() { return d1; } }Epublic abstract class InnerOne { public abstract double methoda(); }

单选题1. public class ReturnIt {  2. return Type methodA(byte x, double y) {  3. return (long)x / y * 2;  4. }  5. }  What is the narrowest valid returnType for methodA in line2?()A intB byteC longD shortE floatF double