单选题Given: What is the result?()A Compilation fails.B exception is thrown at runtime.C The attribute id in the ItemTest object remains unchanged.D The attribute id in the ItemTest object is modified to the new value.E A new ItemTest object is created

题目
单选题
Given: What is the result?()
A

Compilation fails.

B

exception is thrown at runtime.

C

The attribute id in the ItemTest object remains unchanged.

D

The attribute id in the ItemTest object is modified to the new value.

E

A new ItemTest object is created with the preferred value in the id attribute.

参考答案和解析
正确答案: A
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

public class Threads5 {  public static void main (String[] args) {  new Thread(new Runnable() {  public void run() {  System.out.print(”bar”);  } }).start();  }  }  What is the result?() 

  • A、 Compilation fails.
  • B、 An exception is thrown at runtime.
  • C、 The code executes normally and prints “bar”.
  • D、 The code executes normally, but nothing prints.

正确答案:C

第2题:

11. public static void main(String[] args) {  12. Object obj = new Object() {  13. public int hashCode() {  14. returns 42; 15. }  16. };  17. System.out.println(obj.hashCode());  18. }    What is the result? () 

  • A、 42
  • B、 An exception is thrown at runtime.
  • C、 Compilation fails because of an error on line 12.
  • D、 Compilation fails because of an error on line 16.
  • E、 Compilation fails because of an error on line 17.

正确答案:A

第3题:

Given:What is the result?()

A.Compilation fails.

B.exception is thrown at runtime.

C.The attribute id in the ItemTest object remains unchanged.

D.The attribute id in the ItemTest object is modified to the new value.

E.A new ItemTest object is created with the preferred value in the id attribute.


参考答案:A

第4题:

try {  if ((new Object))(.equals((new Object()))) {  System.out.println(“equal”);  }else{  System.out.println(“not equal”);  }  }catch (Exception e) {  System.out.println(“exception”);  }   What is the result? () 

  • A、 equal
  • B、 not equal
  • C、 exception
  • D、 Compilation fails.

正确答案:D

第5题:

public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()  

  • A、 i = 3
  • B、 Compilation fails.
  • C、 A ClassCastException is thrown at line 6.
  • D、 A ClassCastException is thrown at line 7.

正确答案:A

第6题:

public class ItemTest {  private final mt id;  public ItemTest(int id) { this.id = id; }  public void updateId(int newId) { id = newId; }  public static void main(String[] args) {  ItemTest fa = new ItemTest(42);  fa.updateId(69);  System.out.println(fa.id);  }  }  What is the result?() 

  • A、 Compilation fails.
  • B、 An exception is thrown at runtime.
  • C、 The attribute id in the Item object remains unchanged.
  • D、 The attribute id in the Item object is modified to the new value.
  • E、 A new Item object is created with the preferred value in the id attribute.

正确答案:A

第7题:

What happens when thread X executes a wait() method on object A, without owning object A’s lock?()  

  • A、 Compilation fails.
  • B、 An exception is thrown.
  • C、 The wait() method has no effect.
  • D、 Thread X receives the lock immediately.
  • E、 Object A moves the thread to the wait pool.

正确答案:B

第8题:

public class Threads3 implements Runnable {  public void run() {  System.out.print(”running”);  }  public static void main(String[] args) {  Thread t = new Thread(new Threads3());  t.run();  t.run();  t.start();  }  }  What is the result?() 

  • A、 Compilation fails.
  • B、 An exception is thrown at runtime.
  • C、 The code executes and prints “running”.
  • D、 The code executes and prints “runningrunning”.
  • E、 The code executes and prints “runningrunningrunning”.

正确答案:E

第9题:

public class Drink implements Comparable {  public String name;  public int compareTo(Object o) {  return 0;  }  }  and:  Drink one = new Drink();  Drink two = new Drink();  one.name= “Coffee”;  two.name= “Tea”;  TreeSet set = new TreeSet();  set.add(one);  set.add(two);  A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?() 

  • A、 Tea
  • B、 Coffee
  • C、 Coffee Tea
  • D、 Compilation fails.
  • E、 The code runs with no output.
  • F、 An exception is thrown at runtime.

正确答案:B

第10题:

import java.io.*;  public class Forest implements Serializable {  private Tree tree = new Tree();  public static void main(String [] args) {  Forest f= new Forest();  try {  FileOutputStream fs = new FileOutputStream(”Forest.ser”);  ObjectOutputStream os = new ObjectOutputStream(fs);  os.writeObject(f); os.close();  } catch (Exception ex) { ex.printStackTrace(); }  }  }  class Tree { }  What is the result?() 

  • A、 Compilation fails.
  • B、 An exception is thrown at runtime.
  • C、 An instance of Forest is serialized.
  • D、 A instance of Forest and an instance of Tree are both serialized.

正确答案:B

更多相关问题