SUN国际认证试题及答案
作为一个IT工作人员,你有考过SUN认证吗?下面本站小编为大家分享最新的SUN国际认证考试题及答案,希望对大家的学习有所帮助!
h of the following fragments might cause errors?
A. String s = "Gone with the wind";
String t = " good ";
String k = s + t;
B. String s = "Gone with the wind";
String t;
t = s[3] + "one";
C. String s = "Gone with the wind";
String standard = perCase();
D. String s = "home directory";
String t = s - "directory";
answer:(BD)这道题考察java字符串和连接符+的理解,B中s[3]是一个字符,而不能和一个字符串用连接符连起来。而D则是我们初学java时以为有+必定有-,所以导致错误。java中的连接符只有一个就是+。而且字符串和字符是两个不同的概念,我们要区分开来。
2. Given the following code fragment:
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }
Which of the following statements are true?
A. The declaration on line 2 does not allocate memory space for the variable myVect.
B. The declaration on line 2 allocates memory space for a reference to a Vector object.
C. The statement on line 2 creates an object of class Vector.
D. The statement on line 3 creates an object of class Vector.
E. The statement on line 3 allocates memory space for an object of class Vector
answer:(ADE)这题考察获得实例的内存变化。定义一个实例并不能给对象分配内存空间,系统只给定义的那个变量分配空间。只有当new 出一个对象时系统回给一个实例对象分配内存空间。
3. Which are not Java keywords?
A. TRUE
B. sizeof
C. const
D. super
E. void
answer:(AB)sizeof是c++语言的的关键字,不是java的,我做题的时候觉得sizeof很熟悉,想当然以为它就是java的关键字,结果可想而知。
4. Which are not Java primitive(基本) types?
A. short
B. Boolean
C. unit
D. float
answer:(BC)java基本数据类型只有8个,而Boolean是引用数据类型。选错了,关键是没弄清primitive是什么意思,汗颜啊,英语太差了。
5. Which statements about the garbage collection are true?
A. The program developer must create a thread to be responsible for free
the memory.
B. The garbage collection will check for and free memory no longer needed.
C. The garbage collection allow the program developer to explicity and
immediately free the memory.
D. The garbage collection can free the memory used java object at expect
time.
answer:(B)java垃圾自动回收机制,我们不能让虚拟机什么时候开始垃圾回收,垃圾回收是不受我们控制的,就算我们想要快点垃圾回收,我们只能通过一个gc()函数希望快点垃圾回收,但是程序回不回提前垃圾回收还是不知道的'。所以选b。
6、Which of the following assignment is not correct?
A. float f = 11.1;
B. double d = 5.3E12;
C. double d = 3.14159;
D. double d = 3.14D.
answer:(A)记住基本数据类型中int和double都是默认的,所以a是错的,把double转换成float型要强制类型转换。第一次碰到这样的题的时候我全错,不过现在好了。
7、Given the uncompleted code of a class:
class Person {
String name, department;
int age;
public Person(String n){ name = n; }
public Person(String n, int a){ name = n; age = a; }
public Person(String n, String d, int a) {
// doing the same as two arguments version of constructor
// including assignment name=n,age=a
department = d;
}
}
Which expression can be added at the "doing the same as..." part of the constructor?
A. Person(n,a);
B. this(Person(n,a));
C. this(n,a);
D. this(name,age).
answer:(C)这题有较大迷惑,要是不认真看,估计会选d,看看参数列表是n和a,如果选择d的话就错了。
8、public void test() {
try { oneMethod();
tln("condition 1");
} catch (ArrayIndexOutOfBoundsException e) {
tln("condition 2");
} catch(Exception e) {
tln("condition 3");
} finally {
tln("finally");
}
}
Which will display if oneMethod run normally?
A. condition 1
B. condition 2
C. condition 3
D. finally
answer:(AD)finally 修饰的最终都将会运行,所以当程序正常运行,不抛出异常时,AD都将运行。
9 Given the following code fragment:
1) String str = null;
2) if ((str != null) && (th() > 10)) {
3) tln("more than 10");
4) }
5) else if ((str != null) & (th() < 5)) {
6) tln("less than 5");
7) }
8) else { tln("end"); }
Which line will cause error?
A. line 1
B. line 2
C. line 5
D. line 8
answer:(C)&&和&的区别,&是按位与计算,&两边的运算都要执行;&&是逻辑运算,当左边为假时,右边可以不执行。当右边执行时,可能有 (th()空指针异常)。
10、Given the following code:
public class Person{
static int arr[] = new int[10];
public static void main(String a[]) {
tln(arr[1]) ;
}
}
Which statement is correct?
A. When compilation some error will occur.
B. It is correct when compilation but will cause error when running.
C. The output is zero.
D. The output is null.
answer:(C)java数组默认初始化都为0.
-
计算机二级office考试上机必知内容
成为一名程序员首先要掌握一种主流编程语言,学习任意一种主流的编程语言,例如C++语言。下面是小编整理的.关于计算机二级office考试上机必知内容,欢迎大家参考!一、考试内容要求:1、掌握计算机基础知识及计算机系统组成2、了解信息安全的基本知识、掌握计算机病毒...
-
计算机二级考试VF模拟试卷及答案
为帮助大家更好复习计算机二级VF考试的基本知识,本站小编为大家分享计算机二级VF考试模拟试题及答案如下,赶紧来学习吧!基本操作题(共4小题,第1和2题是7分、第3和4题是8分)在考生文件夹下,打开SELLDB数据库,完成如下基本操作:1.创建"客户表"(客户号,客户名,销售金额),其...
-
H3C云计算销售专家认证
H3C云计算销售专家认证是H3C公司推出的针对渠道销售人员资质评定的能力认证,通过该认证的学员已具备基本的云计算产品销售能力,对服务器、存储、云管理平台等云产品和行业应用有了基本了解,能够独立与客户进行日常交流并进一步挖掘用户需求。1.考试及费用代码名称...
-
H3C中小企业无线解决方案
根据中国互联网络信息中心(CNNIC)公布的数据,截至2008年6月底,中国网民数量达到了2.53亿,首次大幅度超过美国,跃居世界第一位。中国也真正地步入网络时代。其中WLAN网络在提高企业效率、降低企业成本、提高用户满意度等方面有着突出的作用。那么随着网络使用范围的...