1. public class 

题目

1. public class X {  2. public object m ()  {  3. object o = new float (3.14F);  4. object [] oa = new object [1]; 5. oa[0]= o;  6. o = null;  7. oa[0] = null;  10. return o;  9. }  10. }  When is the float object created in line 3, eligible for garbage collection?()  

  • A、 Just after line 5.
  • B、 Just after line 6.
  • C、 Just after line 7.
  • D、 Just after line 8(that is, as the method returns).
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given:Which two, inserted at line 11, will allow the code to compile?()

A.public class MinMax<?> {

B.public class MinMax<? extends Number> {

C.public class MinMax<N extends Object> {

D.public class MinMax<N extends Number> {

E.public class MinMax<? extends Object> {

F.public class MinMax<N extends Integer> {


参考答案:D, F

第2题:

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;

正确答案:D

第3题:

下列程序片段中,能通过编译的是

A.public abstract class Animal{ public void speak();}

B.public abstract class Animal{ public void speak(){}}

C.public class Animal{ public abstract void speak();}

D.public abstract class Animal{ public abstract void speak(){}}


正确答案:A

第4题:

Which three demonstrate an “is a” relationship?() 

  • A、 public class X {  }     public class Y extends X { }
  • B、 public interface Shape { }     public interface Rectangle extends Shape{ }
  • C、 public interface Color { }     public class Shape { private Color color; }
  • D、 public interface Species { }     public class Animal { private Species species; }
  • E、 public class Person { }    public class Employee {      public Employee(Person person) { }
  • F、 interface Component { }     class Container implements Component {   private Component[] children; }

正确答案:A,B,F

第5题:

1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

  • A、 Line 33 must be called within a try block.
  • B、 The exception thrown by method1 in class a is not required to be caught.
  • C、 The method declared on line 31 must be declared to throw a RuntimeException.
  • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

正确答案:B

第6题:

public class SomeException {  } Class a:  public class a {  public void doSomething() { }  } Class b:  public class b extends a {  public void doSomething() throws SomeException { }  }  Which is true about the two classes?() 

  • A、 Compilation of both classes will fail.
  • B、 Compilation of both classes will succeed.
  • C、 Compilation of class a will fail. Compilation of class b will succeed.
  • D、 Compilation of class a will fail. Compilation of class a will succeed.

正确答案:D

第7题:

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

第8题:

下列虚基类的声明中正确的是( )。

A.class virtual B:public A

B.virtual class B:public A

C.class B:public A virtual

D.class B:virtual public A


正确答案:D
解析: 虚基类说明格式为:virtual继承方式>基类名>其中,virtual是虚基类的关键词。虚基类的说明是用在定义派生类时,写在派生类名的后面。即:class派生类名>Virtual继承方式>基类名>;

第9题:

1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  

  • A、 Class A
  • B、 Compilation fails.
  • C、 An exception is thrown at line 2.
  • D、 An exception is thrown at line 6.
  • E、 The code executes with no output.

正确答案:E

第10题:

interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

  • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
  • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
  • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
  • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
  • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
  • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

正确答案:A

更多相关问题