网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

Given the following code fragment:      1) String str = null;  2) if ((str != null) && (str.length() > 10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null) & (str.length() < 5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()    

  • A、 line 1
  • B、 line 2
  • C、 line 5
  • D、 line 8

参考答案

更多 “ Given the following code fragment:      1) String str = null;  2) if ((str != null)  (str.length()  10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null)  (str.length()  5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()    A、 line 1B、 line 2C、 line 5D、 line 8” 相关考题
考题 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.nullB.zeroC.someD.Compilationfails.E.Anexceptionisthrownatruntime.

考题 publicstaticvoidmain(String[]args){Stringstr=null?;if(str==null){System.out.println(”null”);}else(str.length()==0){System.out.println(”zero”);}else{System.out.println(”some”);}}Whatistheresult?() A.nullB.zeroC.someD.Compilationfails.E.Anexceptionisthrownatruntime.

考题 Giventhefollowingcodefragment:1)Stringstr=null;2)if((str!=null)(str.length()10)){3)System.out.println(morethan10);4)}5)elseif((str!=null)(str.length()5)){6)System.out.println(lessthan5);7)}8)else{System.out.println(end);}Whichlinewillcauseerror?()A.line1B.line2C.line5D.line8

考题 Whatwillbetheresultofattemptingtorunthefollowingprogram?()publicclassQaa75{publicstaticvoidmain(Stringargs[]){String[][][]arr={{{},null},{{1,2},{1,null,3}},{},{{1,null}}};System.out.println(arr.length+arr[1][2].length);}}A.TheprogramwillterminatewithanArrayIndexOutOfBoundsException.B.TheprogramwillterminatewithaNullPointerException.C.4willbewrittentostandardoutput.D.6willbewrittentostandardoutput.E.7willbewrittentostandardoutput.

考题 publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?() A.NULLB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.

考题 先阅读下面的程序片段:String str="abccdefcdh";String[] arr=str.split"c";System.out.println(arr.length);程序执行后,打印的结果是( )。 A、2个B、3个C、4个D、5个

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

考题 阅读下面程序 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.abeB.ABCC.abcABCD.ABCabc

考题 C#中,string str = null 与 string str =””,请尽量用文字说明区别。(要点:说明详细的内存空间分配)

考题 阅读以下说明,Java代码将应填入(n)处的字句写在对应栏内。【说明】链表和栈对象的共同特征是:在数据上执行的操作与在每个对象中实体存储的基本类型无关。例如,一个栈存储实体后,只要保证最后存储的项最先用,最先存储的项最后用,则栈的操作可以从链表的操作中派生得到。程序6-1实现了链表的操作,程序6-2实现了栈操作。import java.io.*;class Node //定义结点{ private String m_content;private Node m_next;Node(String str){ m_content=str;m_next=null; }Node(String str,Node next){ m_content=str;m_next=next; }String getData() //获取结点数据域{ return m_content;}void setNext(Node next] //设置下一个结点值{ m_next=next; }Node getNext() //返回下一个结点{ return m_next; )}【程序6-1】class List{ Node Head;List(){ Head=null; }void insert(String str) //将数据str的结点插入在整个链表前面{ if(Head==null)Head=new Node(str);else(1)}void append(String str) //将数据str的结点插入在整个链表尾部{ Node tempnode=Head;it(tempnode==null)Heed=new Node(str);else{ white(tempnode.getNext()!=null)(2)(3) }}String get() //移出链表第一个结点,并返回该结点的数据域{ Srting temp=new String();if(Head==null){ System.out.println("Errow! from empty list!")System.exit(0); }else{ temp=Head.getData();(4) }return temp;}}【程序6-2】class Stack extends List{ void push(String str) //进栈{ (5) }String pop() //出栈{ return get();}}

考题 下面的程序各自独立,请问执行下面的四个TestMemory 函数各有什么样的结果?①void GetMemory(char * p){p = (char * )malloc(100);}void TestMemory (void){char *str = NULL;GetMemory (str);strcpy(str, "hello world");prinff(str);}② char * GetMemory (void){char p[ ] = "hello world";return p;}void TestMemory (void){char * str = NULL;str = GetMemory( );printf(str);}③void GetMemory(char * * p, int num){* p = (char * )malloc(num);}void TestMemory (void){char * str = NULL;GetMemory(str, 100);strcpy( str, "hello" );printf(sir);}④void TestMemory (void){char *str = (char * )malloe(100);strepy (str, "hello" );free ( str );if(str ! = NULL){strepy( str, "world" );printf(str);}}

考题 在C#中,string str = null 与 string str = “” 请尽量使用文字或图象说明其中的区别。

考题 下面是一段javabean程序,该程序的运行结果是( )。public class NullTest{public static void main(String[]?args){int M=0;String str=null;StringBuffer sb=new StringBuffer("=");sb.append(str);sb.append(M++);System.out.println(sb.toString( ));}}A.=null B.=null0 C.=null1 D.=nullM

考题 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、 nullB、 zeroC、 someD、 Compilation fails.E、 An exception is thrown at runtime.

考题 public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()  A、 NULLB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.

考题 String str="abcedf"; int length=str.length。

考题 String str; System.out.println(str.length()); 以上语句运行的结果是显示0 。

考题 顺序执行下列程序语句后,则b的值是() String str = "Hello"; String b = str.substring(0,2);A、HelloB、helloC、HeD、null

考题 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、nullB、zeroC、someD、Compilationfails.E、Anexceptionisthrownatruntime.

考题 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.

考题 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.

考题 判断题String str="abcedf"; int length=str.length。A 对B 错

考题 单选题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.

考题 单选题Given the following code fragment:      1) String str = null;  2) if ((str != null)  (str.length()  10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null)  (str.length()  5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()A  line 1B  line 2C  line 5D  line 8

考题 单选题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  nullB  zeroC  someD  Compilation fails.E  An exception is thrown at runtime.

考题 单选题public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()A  NULLB  Compilation fails.C  The code runs with no output.D  An exception is thrown at runtime.

考题 判断题String str; System.out.println(str.length()); 以上语句运行的结果是显示0 。A 对B 错