int index = 1;   int foo = new int ;   int bar = foo [index]

题目
单选题
int index = 1;   int foo = new int ;   int bar = foo [index];   int baz = bar + index;   What is the result?()
A

 Baz has the value of 0

B

 Baz has the value of 1

C

 Baz has the value of 2

D

 An exception is thrown.

E

 The code will not compile.

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

第1题:

下面程序执行后,baz的值应是______。 public class Test9 { public static void main(String[] args) { int index = 1; int fox[] = new int [3]; iht bar = fox [index]; int baz = bar + index; System.out.println(baz); } }

A.0

B.1

C.2

D.编译错误


正确答案:B
解析:int fox[]=new int[3]这时数组的每个元素都初始化为0,所以int baz=bar+index;,其实,这时bar的值为0,这样便有baz的值为1。

第2题:

关于以下初始化序列的执行结果的说法正确的是( )。 int index=1; int[] foo=new int[3]; int bar=foo[index]; int baz=bar+index;

A.baz的值为0

B.baz的值为1

C.编译通过,但产生异常

D.编译不能通过


正确答案:B

第3题:

intindex=1;int[]foo=newint[3];intbar=foo[index];intbaz=bar+index;Whatistheresult?()

A.Bazhasthevalueof0

B.Bazhasthevalueof1

C.Bazhasthevalueof2

D.Anexceptionisthrown.

E.Thecodewillnotcompile.


参考答案:B

第4题:

Which statements concerning the relationships between the following classes are true?()   class Foo {  int num;   Baz comp = new Baz();   }   class Bar {  boolean flag;   }   class Baz extends Foo {   Bar thing = new Bar();   double limit;   }  

  • A、A Bar is a Baz.
  • B、A Foo has a Bar.
  • C、A Baz is a Foo.
  • D、A Foo is a Baz.
  • E、A Baz has a Bar.

正确答案:C,E

第5题:

int index = 1;   String test = new String;   String foo = test[index];  What is the result?()

  • A、  Foo has the value “”
  • B、 Foo has the value null
  • C、 An exception is thrown
  • D、 The code will not compile

正确答案:B

第6题:

写出结果

void foo(int p1[])

{

*p1 += 5;

}

void bar(int p2[])

{

p2[1] = 15;

}

void main()

{

int a[]={3,4,5};

int b[]={3,4,5};

int *p2;

p2=&a[1];

bar(p2);

printf("%i %i %i\n",a[0],a[1],a[2]);

p2=&b[0];

p2++;

foo(p2);

bar(p2);

printf("%i %i %i\n",b[0],b[1],b[2]);

}


正确答案:
 

第7题:

下列程序执行后,baz的值应是 int index=1; int fox[ ]=new int[3]; Int bar=fox[index]; int baz:bar+index;

A.0

B.1

C.2

D.编译错误


正确答案:B
解析:intfox[]=newint[3];这时数组的每个元素都初始化为0,所以intbaz=bar+index;其实,这时bar的值是0,这样便有baz的值1。

第8题:

Given:Which code, inserted at line 15, allows the class Sprite to compile?()

A.Foo { public int bar() { return 1; }

B.new Foo { public int bar() { return 1; }

C.new Foo() { public int bar() { return 1; }

D.new class Foo { public int bar() { return 1; }


参考答案:C

第9题:

Which code determines the int value foo closest to a double value bar?()  

  • A、 Int foo = (int) Math.max(bar);
  • B、 Int foo = (int) Math.min(bar);
  • C、 Int foo = (int) Math.abs(bar);
  • D、 Int foo = (int) Math.ceil(bar);
  • E、 Int foo = (int) Math.floor(bar);
  • F、 Int foo = (int) Math.round(bar);

正确答案:F

第10题:

1. class SuperFoo {  2. SuperFoo doStuff(int x) {  3. return new SuperFoo(); 4. }  5. }  6.  7. class Foo extends SuperFoo {  8. //insert code here  9. }   下面哪三项分别插入到第8行,可以编译?()

  • A、int doStuff() { return 42; }
  • B、int doStuff(int x) { return 42; }
  • C、Foo doStuff(int x) { return new Foo(); }
  • D、SuperFoo doStuff(int x) { return new Foo(); }

正确答案:A,C,D

更多相关问题