CMS专题

单选题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段

题目
单选题
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题:

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.

正确答案:F

第2题:

现有:   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"); }

正确答案:B,C,E

第3题:

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.

正确答案:C

第4题:

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

正确答案:C,D

第5题:

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

正确答案:C,E

第6题:

现有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();

正确答案:C,D

第7题:

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) {

正确答案:C,D

第8题:

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 */ }

正确答案:B,C,E

第9题:

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

正确答案:D

第10题:

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

正确答案:A,C,D,E,F

更多相关问题