public void testIfA(){ if(testIfB("True")){ System.out.print

题目
单选题
public void testIfA(){ if(testIfB("True")){ System.out.println("True"); }else{ System.out.println("Nottrue"); } } public Boolean testIfB(Stringstr){ return Boolean.valueOf(str); } What is the result when method testIfA is invoked?()
A

True

B

Nottrue

C

Anexceptionisthrownatruntime.

D

Compilationfailsbecauseofanerroratline12.

E

Compilationfailsbecauseofanerroratline19.

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

第1题:

下列选项中,哪个是程序的运行结果class Test{public static void main(String[] args) {int a = 3;int b = 6;System.out.print(a==b);System.out.print(aSystem.out.print(a!=b);System.out.print(a>=b);}}

A.false false true false

B.false false true true

C.false true true false

D.true false false true


答案:C
解析:3==6(错),3<6(对),3!=6(对),3>=6(错)

第2题:

public class Test {  public static void main(String [] args) {  int x =5;  boolean b1 = true;  boolean b2 = false;  if((x==4) && !b2)  System.out.print(”l “);  System.out.print(”2 “);  if ((b2 = true) && b1)  System.out.print(”3 “);  } }  What is the result?() 

  • A、 2
  • B、 3
  • C、 1 2
  • D、 2 3
  • E、 1 2 3
  • F、 Compilation fails.
  • G、 Au exceptional is thrown at runtime.

正确答案:D

第3题:

public class Test{public static void main(String[]args){intx=5;boolean b1=true;boolean b2=false;if((x==4)&&!b2)System.out.print("l");System.out.print("2");if((b2=true)&&b1)System.out.print("3");}}What is the result?()

A.2

B.3

C.12

D.23

E.123

F.Compilation fails.

G.An exceptional ist hrown at runtime.


参考答案:D

第4题:

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

第5题:

11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?() 

  • A、 True
  • B、 Not true
  • C、 An exception is thrown at runtime.
  • D、 Compilation fails because of an error at line 12.
  • E、 Compilation fails because of an error at line 19.

正确答案:A

第6题:

以下程序的运行结果为?

class ValHold{

public int i = 10;

}

public class ObParm{

public static void main(String argv[]){

ObParm o = new ObParm();

o.amethod();

}

public void amethod(){

int i = 99;

ValHold v = new ValHold();

v.i=30;

another(v,i);

System.out.print( v.i );

}

public void another(ValHold v, int i){

i=0;

v.i = 20;

ValHold vh = new ValHold();

v = vh;

System.out.print(v.i);

System.out.print(i);

}

}

A.10030

B. 20030

C. 209930

D. 10020


正确答案:D

第7题:

public class Pet{     private String name;     public Pet(String name){       this.name = name;    }  public void speak(){     System.out.print(name); }  }  public class Dog extends Pet{     public Dog(String name){       super(name);    }  public void speak(){    super.speak();  System.out.print(“ Dog ”);    } }  执行代码   Pet pet = new Dog(“京巴”);  pet.speak();  后输出的内容是哪项?() 

  • A、 京巴
  • B、 京巴 Dog
  • C、 null
  • D、 Dog京巴

正确答案:B

第8题:

下列代码的执行结果是______。 public class ex55 { public static void main(String args[] ) { String s1=new String("hello"); String s2=new String("hello"); System.out.print (s1==s2); System.out.print (","); System.out.println (s1.equals (s2)); } }

A.true, false

B.true, true

C.false, true

D.false, false


正确答案:C

第9题:

public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new Error();  }  }  What is the result?()  

  • A、 ABCD
  • B、 Compilation fails.
  • C、 C is printed before exiting with an error message.
  • D、 BC is printed before exiting with an error message.
  • E、 BCD is printed before exiting with an error message.

正确答案:B

第10题:

public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”); }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }   public static void badMethod() {} }  What is the result?()  

  • A、 AC
  • B、 BD
  • C、 ACD
  • D、 ABCD
  • E、 Compilation fails.

正确答案:C

更多相关问题