单选题1. class Passer2 {   2. //insert code here   3. static int bigState = 42;   4. public static void main(String [] args) {   5. bigState = p2.go(bigState);   6. System.out.print(bigState);   7. }   8. int go(int x) {   9. return ++x;   10. }   11. }  和4段代码片段:  static Passer2 p2 = new Passer2();  final static Passer2 p2 = new Passer2();  private static Passer2 p2 = new Passer2();  final private static Passer2 p2 = new Passer2();  有多少行分别插入到第2行,可以编译?()A0B1C3D4

单选题
1. class Passer2 {   2. //insert code here   3. static int bigState = 42;   4. public static void main(String [] args) {   5. bigState = p2.go(bigState);   6. System.out.print(bigState);   7. }   8. int go(int x) {   9. return ++x;   10. }   11. }  和4段代码片段:  static Passer2 p2 = new Passer2();  final static Passer2 p2 = new Passer2();  private static Passer2 p2 = new Passer2();  final private static Passer2 p2 = new Passer2();  有多少行分别插入到第2行,可以编译?()
A

0

B

1

C

3

D

4


参考解析

解析: 暂无解析

相关考题:

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.

class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()A、 int foo() { /* more code here */ }B、 void foo() { /* more code here */ }C、 public void foo() { /* more code here */ }D、 private void foo() { /* more code here */ }E、 protected void foo() { /* more code here */ }

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.

现有2 个文件:  1. package x;  2. public class X {  3. public static void doX() { System.out.print("doX "); }  4. }  和:  1. class Find {  2. public static void main(String [] args) {  3. //insert code here  4. }  5. }  哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()A、doX();B、X.doX();C、x.X.doX();D、x.X myX = new x.X(); myX.doX();

现有:   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. class Calc {  2. public static void main(String [] args) {  3. try {  4. int x = Integer.parseInt("42a");  5. //insert code here  6. System.out.print("oops ");  7. }  8. }  9. }  下面哪两行分别插入到第五行,会导致输出“oops”?()A、} catch (ClassCastException c) {B、} catch (IllegalStateException c) {C、} catch (NumberFormatException n) {D、} catch (IllegalArgumentException e) {

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(); }

1. public class enclosingone (  2. public class insideone{}  3. )  4. public class inertest(  5. public static void main (string[]args)(  6. enclosingone eo= new enclosingone ();  7. //insert code here  8. )  9. )    Which statement at line 7 constructs an instance of the inner class?()  A、 InsideOnew ei= eo.new InsideOn();B、 Eo.InsideOne ei = eo.new InsideOne();C、 InsideOne ei = EnclosingOne.new InsideOne();D、 EnclosingOne.InsideOne ei = eo.new InsideOne();

1. class BigDog extends Dog {  2. // insert code here  3. }  分别插入到第 2 行,哪二项可以编译?()A、BigDog() { super(); this(); }B、BigDog() {  String name = "Fido";  super();  }C、BigDog() {  super();  String name = "Fido";  }D、private BigDog() {  super();}

1. public class Blip {  2. protected int blipvert(int x) { return 0; }  3. }  4. class Vert extends Blip {  5. // insert code here  6. }  Which five methods, inserted independently at line 5, will compile?()  A、 public int blipvert(int x) { return 0; }B、 private int blipvert(int x) { return 0; }C、 private int blipvert(long x) { return 0; }D、 protected long blipvert(int x, int y) { return 0; }E、 protected int blipvert(long x) { return 0; }F、 protected long blipvert(long x) { return 0; }G、protected long blipvert(int x) { return 0; }

Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()A、 public void foo() { /* more code here */ }B、 private void foo() { /* more code here */ }C、 protected void foo() { /* more code here */ }D、 int foo() { /* more code here */ }  E、 void foo() { /* more code here */ }

现有:   1. interface Altitude {   2.   //insert code here  3. }    和4个声明:  int HIGH = 7;   public int HIGH = 7;   abstract int HIGH = 7;   interface int HIGH = 7;    分别插入到第2行,有多少行可以编译?()  A、 0B、 1C、 2D、 3E、 4

多选题1. class SuperFoo {  2. SuperFoo doStuff(int x) {  3. return new SuperFoo(); 4. }  5. }  6.  7. class Foo extends SuperFoo {  8. //insert code here  9. }   下面哪三项分别插入到第8行,可以编译?()Aint doStuff() { return 42; }Bint doStuff(int x) { return 42; }CFoo doStuff(int x) { return new Foo(); }DSuperFoo doStuff(int x) { return new Foo(); }

多选题现有2 个文件:  1. package x;  2. public class X {  3. public static void doX() { System.out.print("doX "); }  4. }  和:  1. class Find {  2. public static void main(String [] args) {  3. //insert code here  4. }  5. }  哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()AdoX();BX.doX();Cx.X.doX();Dx.X myX = new x.X(); myX.doX();

多选题1. class Synapse {   2. protected int gap() { return 7; }   3. }   4.   5. class Creb extends Synapse { 6. // insert code here  7. }  分别插入到第 6 行,哪三行可以编译?()Aint gap() { return 7; }Bpublic int gap() { return 7; }Cprivate int gap(int x) { return 7; }Dprotected Creb gap() { return this; }Epublic int gap() { return Integer.getInteger (42); }

单选题1. class Passer2 {   2. //insert code here   3. static int bigState = 42;   4. public static void main(String [] args) {   5. bigState = p2.go(bigState);   6. System.out.print(bigState);   7. }   8. int go(int x) {   9. return ++x;   10. }   11. }  和4段代码片段:  static Passer2 p2 = new Passer2();  final static Passer2 p2 = new Passer2();  private static Passer2 p2 = new Passer2();  final private static Passer2 p2 = new Passer2();  有多少行分别插入到第2行,可以编译?()A0B1C3D4

多选题1. class BigDog extends Dog {  2. // insert code here  3. }  分别插入到第 2 行,哪二项可以编译?()ABigDog() { super(); this(); }BBigDog() {  String name = Fido;  super();  }CBigDog() {  super();  String name = Fido;  }Dprivate BigDog() {  super();}

单选题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 Calc {  2. public static void main(String [] args) {  3. try {  4. int x = Integer.parseInt("42a");  5. //insert code here  6. System.out.print("oops ");  7. }  8. }  9. }  下面哪两行分别插入到第五行,会导致输出“oops”?()A} catch (ClassCastException c) {B} catch (IllegalStateException c) {C} catch (NumberFormatException n) {D} catch (IllegalArgumentException e) {

多选题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(); }

单选题public class Score implements Comparable {  private int wins, losses;  public Score(int w, int 1) { wins = w; losses = 1; }  public int getWins() { return wins; }  public int getLosses() { return losses; }  public String toString() {  return “”; }  // insert code here  }  Which method will complete this class?()A public int compareTo(Object o) {/*mode code here*/}B public int compareTo(Score other) {/*more code here*/}C public int compare(Score s1,Score s2){/*more code here*/}D public int compare(Object o1,Object o2){/*more code here*/}

单选题1. class Over{   2. int doIt(long x) { return 3;}   3. }   4.   5. class Under extends Over{   6. //insert code here 7. }   和四个方法:   short doIt(int y) {return 4;}   int doIt(long x,long y){return 4;}   private int doIt(Short y){ return 4;}   protected int doIt(long x){return 4;}   分别插入到第6行,有几个可以通过编译?()A2B3C4D0E1

多选题1. class HorseRadish {   2. // insert code here   3. protected HorseRadish(int x) {  4. System.out.println("bok choy");   5. }   6. }   7. class Wasabi extends HorseRadish {   8. public static void main(String [] args) {   9. Wasabi w = new Wasabi();  10. }   11. }   分别插入到第 2 行,哪两项允许代码编译并产生"bok choy" 输出结果?()A// just a commentBprotected HorseRadish() { }Cprotected HorseRadish() { this(42);}Dprotected HorseRadish() { new HorseRadish (42);}

单选题现有:   1. interface Altitude {   2.   //insert code here  3. }    和4个声明:  int HIGH = 7;   public int HIGH = 7;   abstract int HIGH = 7;   interface int HIGH = 7;    分别插入到第2行,有多少行可以编译?()A 0B 1C 2D 3E 4

单选题Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A import utils.*;B static import utils.*;C import utils.Repetition.*;D static import utils.Repetition. *;E import utils.Repetition.twice();F import static utils.Repetition.twice;G static import utils.Repetition.twice;

多选题1. public class Blip {  2. protected int blipvert(int x) { return 0; }  3. }  4. class Vert extends Blip {  5. // insert code here  6. }  Which five methods, inserted independently at line 5, will compile?()Apublic int blipvert(int x) { return 0; }Bprivate int blipvert(int x) { return 0; }Cprivate int blipvert(long x) { return 0; }Dprotected long blipvert(int x, int y) { return 0; }Eprotected int blipvert(long x) { return 0; }Fprotected long blipvert(long x) { return 0; }Gprotected long blipvert(int x) { return 0; }

多选题现有:   1. class Synapse {    2.    protected int gap() { return 7; }    3. }   4.     5. class Creb extends Synapse {    6.   // insert code here   7. }    分别插入到第 6 行,哪三行可以编译?()Aint gap() { return 7; }Bpublic int gap() { return 7; }Cprivate int gap(int x) { return 7; }Dprotected Creb gap() { return this; }Epublic int gap() { return Integer.getInteger (42); }