line 1
line 2
line 5
line 8
第1题:
A.null
B.zero
C.some
D.Compilationfails.
E.Anexceptionisthrownatruntime.
第2题:
C#中,string str = null 与 string str =””,请尽量用文字说明区别。(要点:说明详细的内存
空间分配)
第3题:
What happens when you try to compile and run the following program?
class Mystery{String s;public static void main(String[] args){
Mystery m=new Mystery();m.go();}void Mystery(){s=”constructor”;}void go(){System.out.println(s);}
}()
A.this code will not compile
B.this code compliles but throws an exception at runtime
C.this code runs and “constructor” in the standard output
D.this code runs and writes “null” in the standard output
第4题:
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?()
第5题:
在C#中,string str = null 与 string str = “” 请尽量使用文字或图象说明其中的区别。
第6题:
If possible please suggest further improvement of the String class.
Question 3:
Given a link list, detect whether it's circular using only one loop.
Tips: Below implementation is allowed
for( ... )
{
...
}
The following implementations is NOT allowed
...
for( ... )
{
...
for( ... ) {...}
}
...
or
...
for( p = list->head, q = list->head; p != NULL && q != NULL; p = p->next )
{
...
}
...
for( ... )
{
...
}
第7题:
阅读以下说明,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();}
}
第8题:
下面是一段javabean程序,该程序的运行结果是(62)。 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
第9题:
public class foo { public static void main (Stringargs) { String s; system.out.printIn (“s=” + s); } } What is the result?()
第10题:
public class Test { public static void main(String[] args) { String str = NULL; System.out.println(str); } } What is the result?()