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

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

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

B

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

C

 Compilation fails.

D

 An exception is thrown at runtime.

E

 The attribute id in the Item object remains unchanged.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

第2题:

Runnable r = new Runnable() {  public void run() {  System.out.print(”Cat”);  }  };  Threadt=new Thread(r) {  public void run() {  System.out.print(”Dog”);  }  };  t.start();  What is the result?() 

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

正确答案:B

第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题:

12. Date date = new Date();  13. df.setLocale(Locale.ITALY);  14. String s = df.format(date);  The variable df is an object of type DateFormat that has been initialized in line 11. What is the result if this code is run on December 14, 2000?() 

  • A、 The value of s is 14-dic-2004.
  • B、 The value of s is Dec 14, 2000.
  • C、 An exception is thrown at runtime.
  • D、 Compilation fails because of an error in line 13.

正确答案:D

第6题:

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

第7题:

Given that Thing is a class, how many objects and reference variables are created by the following code?()   Thing item, stuff;   item = new Thing();   Thing entity = new Thing();

  • A、One object is created
  • B、Two objects are created
  • C、Three objects are created
  • D、One reference variable is created
  • E、Two reference variables are created
  • F、Three reference variables are created.

正确答案:B,F

第8题:

Click the Exhibit button. Given: ClassA a = new ClassA(); a.methodA(); What is the result? ()

A.Compilation fails.

B.ClassC is displayed.

C.The code runs with no output.

D.An exception is thrown at runtime.


参考答案:D

第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题:

public class ClassA {  public int getValue() {  int value=0;  boolean setting = true;  String title=”Hello”;  (value || (setting && title == “Hello”)) { return 1; }  (value == 1 & title.equals(”Hello”)) { return 2; }  }  } And:  ClassA a = new ClassA();  a.getValue();  What is the result?() 

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

正确答案:C

更多相关问题