Which two code fragments correc

题目

Which two code fragments correctly create and initialize a static array of int elements()

  • A、static final int[]a={100,200};
  • B、static final int[]a;static{a=new int[2];a[0]=100;a[1]=200;}
  • C、static final int[]a=new int[2]{100,200};
  • D、static final int[]a;static void int(){a=new int[3];a[0]=100;a[1]=200;}
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given that: Gadget has-a Sprocket and Gadget has-a Spring and Gadget is-a Widget and Widget has-a Sprocket Which two code fragments represent these relationships? ()

A.

B.

C.

D.

E.

F.


参考答案:A, C

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

正确答案:B,C,E

第3题:

Given: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

第4题:

Which two code fragments will execute the method doStuff() in a separate thread?()

  • A、new Thread() {public void run() { doStuff(); }};
  • B、new Thread() {public void start() { doStuff(); }};
  • C、new Thread() {public void start() { doStuff(); }}.run();
  • D、new Thread() {public void run() { doStuff(); }}.start();
  • E、new Thread(new Runnable() {public void run() { doStuff(); }}).start();

正确答案:D,E

第5题:

public class Team extends java.util.LinkedList {  public void addPlayer(Player p) {  add(p);  }  public void compete(Team opponent) { /* more code here */ }  }  class Player { /* more code here */ }  Which two are true?()

  • A、 This code will compile.
  • B、 This code demonstrates proper design of an is-a relationship.
  • C、 This code demonstrates proper design of a has-a relationship.
  • D、 A Java programmer using the Team class could remove Player objects from a Team object.

正确答案:A,D

第6题:

Embedded systems always require the user to manipulate bits in

registers or variables. Given an integer variable a, write two code fragments.

The first should set bit 5 of a. The second shnuld clear bit 5 of a. In both

cases, the remaining bits should be unmodified.


正确答案:
 

第7题:

The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?()  

  • A、char ch = 65;
  • B、char ch = ’¥65’;
  • C、char ch = ’¥0041’;
  • D、char ch = ’A’;
  • E、char ch = "A";

正确答案:A,D

第8题:

Click the Exhibit button. Given:Which two statements are true if a NullPointerException is thrown on line 3 of class C? ()

A.The application will crash.

B.The code on line 29 will be executed.

C.The code on line 5 of class A will execute.

D.The code on line 5 of class B will execute.

E.The exception will be propagated back to line 27.


参考答案:B, E

第9题:

Which code fragments will succeed in initializing a two-dimensional array named tab with a size that will cause the expression tab[3][2] to access a valid element?()   CODE FRAGMENT a:  int[][] tab = {  { 0, 0, 0 },  { 0, 0, 0 }  };   CODE FRAGMENT b:  int tab[][] = new int[4][];  for (int i=0; i   CODE FRAGMENT c:  int tab[][] = {  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0  };   CODE FRAGMENT d:  int tab[3][2];   CODE FRAGMENT e:  int[] tab[] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };  

  • A、Code fragment a.
  • B、Code fragment b.
  • C、Code fragment c.
  • D、Code fragment d.
  • E、Code fragment e.

正确答案:B,E

第10题:

多选题
Click the Exhibit button.   Given: Which two statements are true if a NullPointerException is thrown on line 3 of class C?()
A

The application will crash.

B

The code on line 29 will be executed.

C

The code on line 5 of class A will execute.

D

The exception will be propagated back to line 27.

E

The code on line 5 of class B will execute.


正确答案: A,D
解析: 暂无解析

更多相关问题