单选题11. public static void test(String str) {  12. if(str == null | str.lellgth() == 0) {  13. System.out.println(”String is empty”);  14. } else {  15. System.out.println(”String is not empty”);  16. }  17. }  And the invocation:  31. test(llull);  What i

题目
单选题
11. public static void test(String str) {  12. if(str == null | str.lellgth() == 0) {  13. System.out.println(”String is empty”);  14. } else {  15. System.out.println(”String is not empty”);  16. }  17. }  And the invocation:  31. test(llull);  What is the result?()
A

 Au exception is thrown at runtime.

B

 “String is empty” is printed to output.

C

 Compilation fails because of au error in line 12.

D

 “String is not empty” is printed to output.


相似考题
更多“11. public static void test(String str) {  12. if(str == nul”相关问题
  • 第1题:

    阅读下面程序 public class ConcatTest{ public static void main(String[] args) { String strl = "abc"; String str2 = "ABC"; String str3 = str1.concat(str2); System.out.println(str3); } } 程序的运行结果是:

    A.abe

    B.ABC

    C.abcABC

    D.ABCabc


    正确答案:C
    解析:本题考查字符串的使用。String类提供concat(str)方法,该方法将当前字符串对象与指定str字符串相连。题目程序中生成两个字符串变量str1和str2,并为其赋值,然后生成一个字符串变量str3,该字符串变量的值为表达式str1.concat(str2)的结果。表达式str1.concat(str3)是把字符串str1与字符串str2相连,结果为“abcABC”。
    因此,程序的运行结果是“abcABC”。本题的正确答案是选项C。

  • 第2题:

    4 . 写出程序的输出结果

    class Class1 {

    private string str = "Class1.str";

    private int i = 0;

    static void StringConvert(string str) {

    str = "string being converted.";

    }

    static void StringConvert(Class1 c) {

    c.str = "string being converted.";

    }

    static void Add(int i) {

    i++;

    }

    static void AddWithRef(ref int i) {

    i++;

    }

    static void Main() {

    int i1 = 10;

    int i2 = 20;

    string str = "str";

    Class1 c = new Class1();

    Add(i1);

    AddWithRef(ref i2);

    Add(c.i);

    StringConvert(str);

    StringConvert(c);

    Console.WriteLine(i1);

    Console.WriteLine(i2);

    Console.WriteLine(c.i);

    Console.WriteLine(str);

    Console.WriteLine(c.str);

    }

    }


    正确答案:
     

  • 第3题:

    char *GetMemory(void){ char p[] = "hello world";return

    p; }void Test(void){char *str = NULL;str = GetMemory(); printf(str);}请问运行 Tes

    t 函数会有什么样的结果?


    正确答案:
     

  • 第4题:

    说出下面几个函数的区别:

    private void test(string str){…}

    private void test(ref string str){…}

    private void test(out string str){…}

    如果一个页面与数据


    正确答案:
     

  • 第5题:

    下列程序通过实现Runnable接口创建一个线程,选择正确的语句填入程序的横线处。 class MyRun implements Runnable { String str; MyRun(String s) { str = s; } public void run() System.out.println(str); } } public class ex40 { public static void main(String[] args) { String name = "实现阶段Runnable 接口"; MyRun my = new MyRun(name); Thread th = th. start ( ); } }

    A.new MyRun(my)

    B.new Thread()

    C.new Thread(my)

    D.Thread(my)


    正确答案:C

  • 第6题:

    public class TestString 1 {  public static void main(String[] args) {  String str = “420”;  str += 42;  System.out.print(str);  }  }  What is the output?()

    • A、 42
    • B、 420
    • C、 462
    • D、 42042
    • E、 Compilation fails.
    • F、 An exception is thrown at runtime.

    正确答案:D

  • 第7题:

    public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()

    • A、 null
    • B、 zero
    • C、 some
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第8题:

    public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()  

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

    正确答案:B

  • 第9题:

    public static void test(String str) { int check = 4;  if (check = str.length()) {  System.out.print(str.charAt(check -= 1) +“, “);  } else {  System.out.print(str.charAt(0) + “, “);  }  }  and the invocation:  test(”four”);  test(”tee”); test(”to”);  What is the result?() 

    • A、 r, t, t,
    • B、 r, e, o,
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:C

  • 第10题:

    单选题
    11. public static void test(String str) {  12. if(str == null | str.lellgth() == 0) {  13. System.out.println(”String is empty”);  14. } else {  15. System.out.println(”String is not empty”);  16. }  17. }  And the invocation:  31. test(llull);  What is the result?()
    A

     Au exception is thrown at runtime.

    B

     “String is empty” is printed to output.

    C

     Compilation fails because of au error in line 12.

    D

     “String is not empty” is printed to output.


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

  • 第11题:

    单选题
    public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()
    A

     NULL

    B

     Compilation fails.

    C

     The code runs with no output.

    D

     An exception is thrown at runtime.


    正确答案: D
    解析: NULL should be "null".

  • 第12题:

    单选题
    public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()
    A

     null

    B

     zero

    C

     some

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第13题:

    void setmemory(char **p, int num)

    { *p=(char *) malloc(num);}

    void test(void)

    { char *str=NULL;

    getmemory(&str,100);

    strcpy(str,"hello");

    printf(str);

    }

    运行test函数有什么结果?( )


    正确答案:
     

  • 第14题:

    void GetMemory(char *p){p = (char *)malloc(100);}void Test(void) {char *str

    = NULL;GetMemory(str); strcpy(str, "hello world");printf(str);}请问运行 Test 函数

    会有什么样的结果?


    正确答案:
     

  • 第15题:

    void Test(void){char *str = (char *)

    malloc(100); strcpy(str, “hello”); free(str); if(str != NULL) { strcpy(str, “

    world”); printf(str);}}请问运行 Test 函数会有什么样的结果?


    正确答案:
     

  • 第16题:

    指出下列程序运行的结果 ( ) public class Example{ String str=new String("good"); char[]ch={'a','b','c'}; public static void main(String args[]){ Example ex=new Example(); ex.change(ex.otr,ex.ch); System.out.print(ex.str+"and"); System.out.print(ex.ch); } public void change(String str,char ch[])} str="test ok"; ch[0]≈'g'; } }

    A.good and abc

    B.good and gbc

    C.test ok and abc

    D.test ok and gbc


    正确答案:B

  • 第17题:

    下列程序运行的结果为:

    public class Example{

    String str=new String("good");

    char[] ch={'a','b','c'};

    public static void main(String args[]){

    Example ex=new Example();

    ex.change(ex.str,ex.ch);

    System.out.print(ex.str+" and ");

    Sytem.out.print(ex.ch);

    }

    public void change(String str,char ch[]){

    str="test ok";

    ch[0]='g';

    }

    }

    A. good and abc

    B. good and gbc

    C. test ok and abc

    D. test ok and gbc


    正确答案:B

  • 第18题:

    public static void parse(String str) {  try {  float f= Float.parseFloat(str);  } catch (NumberFormatException nfe) {  f= 0;  } finally {  System.out.println(f);  }  }  public static void main(String[] args) {  parse(”invalid”);  }  What is the result?() 

    • A、 0.0
    • B、 Compilation fails.
    • C、 A ParseException is thrown by the parse method at runtime.
    • D、 A NumberFormatException is thrown by the parse method at runtime.

    正确答案:B

  • 第19题:

    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

  • 第20题:

    public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()

    • A、null
    • B、zero
    • C、some
    • D、Compilationfails.
    • E、Anexceptionisthrownatruntime.

    正确答案:D

  • 第21题:

    单选题
    public class TestString 1 {  public static void main(String[] args) {  String str = “420”;  str += 42;  System.out.print(str);  }  }  What is the output?()
    A

     42

    B

     420

    C

     462

    D

     42042

    E

     Compilation fails.

    F

     An exception is thrown at runtime.


    正确答案: F
    解析: 暂无解析

  • 第22题:

    单选题
    public static void test(String str) { int check = 4;  if (check = str.length()) {  System.out.print(str.charAt(check -= 1) +“, “);  } else {  System.out.print(str.charAt(0) + “, “);  }  }  and the invocation:  test(”four”);  test(”tee”); test(”to”);  What is the result?()
    A

     r, t, t,

    B

     r, e, o,

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    public static void parse(String str) {  try {  float f= Float.parseFloat(str);  } catch (NumberFormatException nfe) {  f= 0;  } finally {  System.out.println(f);  }  }  public static void main(String[] args) {  parse(”invalid”);  }  What is the result?()
    A

     0.0

    B

     Compilation fails.

    C

     A ParseException is thrown by the parse method at runtime.

    D

     A NumberFormatException is thrown by the parse method at runtime.


    正确答案: C
    解析: 暂无解析

  • 第24题:

    单选题
    public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()
    A

    null

    B

    zero

    C

    some

    D

    Compilationfails.

    E

    Anexceptionisthrownatruntime.


    正确答案: B
    解析: 暂无解析