1 / 14
文档名称:

java笔试题1.doc

格式:doc   大小:39KB   页数:14
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

java笔试题1.doc

上传人:mh900965 2017/12/31 文件大小:39 KB

下载得到文件列表

java笔试题1.doc

相关文档

文档介绍

文档介绍:will be the output when pile and execute the following program.
public class Base{
private void test() {
(6 + 6 + "(Result)");
}
static public void main(String[] a) {
new Base().test();
}
}
Select most appropriate answer.
A 66(Result)
B 12(Result)
C Runtime type for +. Can't convert an int to a string.
pilation type for +. Can't add a string to an int.
解答:B
考点:字符串与基本数据的链接
如果第一个是字符串那么后续都按字符串进行处理
如果第一个到第n个是基本数据,第n+1个是字符串,那么前n个数据都按加法计算,再与字符串链接
2..What will be the output when pile and execute the following program. The symbol ’⌴’ means space.
1:public class Base{
2:
3: private void test() {
4:
5: String aStr = "⌴ One⌴";
6: String bStr = aStr;
7: ();
8: ();
9: ("[" + aStr + "," + bStr + "]");
7: }
8:
9: static public void main(String[] a) {
10: new Base().test();
11: }
12: }
Select most appropriate answer.
A [ONE,⌴ One⌴]
B [⌴ One⌴,One]
C [ONE,One]
D [ONE,ONE]
E [⌴ One⌴,⌴ One⌴]
解答:E
通过 String bStr = aStr;这句代码使 bStr 和 aStr 指向同一个地址空间。String 类是定长字符串,调用一个字符串的方法以后会形成一个新的字符串。
语言中,String 类的 indexOf()方法返回的类型是?
A、Int16 B、Int32 C、int D、long
解答:C
indexOf 方法的声明为:public int indexOf(int ch)
返回指定字符在字符串中第一次出现的索引,如果未出现该字符,则返回-1
4..执行下列代码后,哪个结论是正确的 String[] s=new String[10];
A. s[9] 为 null;
B. s[10] 为"";
C. s[0] 为未定义
D. 为 10
解答:AD
s 是引用类型,s 中的每一个成员都是引用类型,即 String 类型,String 类型默认的值为 null,s 数组的长度为 10。
5. Given:
public class Test {
public static void main(String[] args) {
String str = NULL;
(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
null 应该小写
6、Given:
public class Test {
public static void main (String args[]) {
class Foo {
public int i = 3;
}
Object o = (Object) new Foo();
Foo foo = (Foo)o;
();
}
}
What is the result?
A. Compilation will fail.
B. Compilation