SUN认证考试面试题
SUN认证是给网络设计界建立的一套认证标准,Sun公司推出了Java以及Solaris技术认证方案。以下是小编整理的关于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.
11、Given the following code:
public class Person{
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:(A)这道题看起来跟前一个题一样,但是仔细看的话这次的数组没有声明为static,所以静态main方法不能直接调用,所以编译时会有错误。
12、Which fragments are correct in Java source file?
A. package testpackage;
public class Test{//do something...}
B. import .*;
package testpackage;
public class Test{// do something...}
C. import .*;
class Person{// do something...}
public class Test{// do something...}
D. import .*;
import .*;
public class Test{// do something...}
answer:(ACD)关于包的引用等。包必须在impotr的前面,既是包在最上面。可以没有包的声明。
13:String s= "hello";
String t = "hello";
char c[] = {h,e,l,l,o} ;
Which return true?
A. ls(t);
B. ls(c);
C. s==t;
D. ls(new String("hello"));
E. t==c.
answer:(ACD)这是String,s和t没有new 所以只是声明了两个变量,ACD都正确。
14、public class Parent {
public int addValue( int a, int b) {
int s;
s = a+b;
return s;
}
}
class Child extends Parent {
}
Which methods can be added into class Child?
A. int addValue( int a, int b ){// do something...}
B. public void addValue (){// do something...}
C. public int addValue( int a ){// do something...}
D. public int addValue( int a, int b )throws MyException {//do something...}
answer:(BC)涉及到方法的重写和覆盖,三同一不低,A是默认的,但是父类是public的,不满足不低的原则。看题要仔细。
-
2017计算机二级考试C语言冲刺题及答案
好的复习题是备考计算机二级考试C语言的关键,为了让考生更好地复习。本站小编为大家准备了计算机二级C语言冲刺题。欢迎阅读。一、选择题(1)下列关于栈叙述正确的是A)栈顶元素最先能被删除B)栈顶元素最后才能被删除C)栈底元素永远不能被删除D)以上三种说法都不...
-
2016下半年计算机二级VB上机考试答题攻略
计算机等级考试进入冲刺备考阶段,为帮助同学们考过计算机等级考试,本站小编为大家分享的是二级VB上机考试答题攻略——常用算法,希望对同学们考试有所帮助!常用算法熟练地掌握算法原理、编程思想和代码实现,就能够做到举一反三,轻松备考,顺利过关。1.累加...
-
2017年浙江省计算机三级网络技术考试试题
计算机网络包括计算机和网络两部分.其中计算机又称电子计算机,俗称电脑,是一种能够按照程序运行,自动、高速处理海量数据的现代化智能电子设备。下面是小编整理的关于计算机三级网络技术考试试题,欢迎大家参考!1).对于下列说法,错误的是()。协议可以提供可靠的数据...
-
2017年计算机二级MSOffice上机操作题及答案
2017年NCRE继续实施2013年版考试大纲(部分科目有修订),大纲和教材详情可查询本网站大纲教材栏目。下面是小编收集的计算机二级MSOffice上机操作题及答案,希望可以帮助大家!一、字处理题请在【答题】菜单下选择【进入考生文件夹】命令,并按照题目要求完成下面的操...