SUN认证 百分网手机站

SUN国际认证试题及答案

时间:2018-03-28 11:12:53 SUN认证 我要投稿

SUN国际认证试题及答案

  作为一个IT工作人员,你有考过SUN认证吗?下面yjbys小编为大家分享最新的SUN国际认证考试题及答案,希望对大家的学习有所帮助!

  1.Which 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 = s.toUpperCase();

  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();

  System.out.println("condition 1");

  } catch (ArrayIndexOutOfBoundsException e) {

  System.out.println("condition 2");

  } catch(Exception e) {

  System.out.println("condition 3");

  } finally {

  System.out.println("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) && (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

  answer:(C)&&和&的区别,&是按位与计算,&两边的运算都要执行;&&是逻辑运算,当左边为假时,右边可以不执行。当右边执行时,可能有 (str.length()空指针异常)。

  10、Given the following code:

  public class Person{

  static int arr[] = new int[10];

  public static void main(String a[]) {

  System.out.println(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.

【SUN国际认证试题及答案】相关文章:

1.sun公司国际认证试题及答案

2.Sun国际认证

3.Sun国际认证考试试题

4.Sun国际认证 中国注册 在京正式启动

5.Sun Solaris 国际认证考试流程表

6.Sun国际认证考试证书查询

7.SUN认证Java2程序员考试题及答案

8.2016年Sun认证重点试题