分享
 
 
 

SUN样题测试及答案

王朝java/jsp·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

NEW SUN CERTIFIED PROGRAMMER FOR THE JAVA 2 PLATFORM SAMPLE QUESTIONS

1. Given:

public class ArrayTest {

public static void main (String[] args) {

Object[] ov;

String[] sa = { "Green", "Blue", "Red" };

ov = sa;

System.out.println("Color = " + ov[1]);

}

}

What is the result?

fails to compile

prints Color=Blue

prints Color=Green

generates an exception at runtime

2. Given:

public class OuterClass {

private double d1 = 1.0;

//insert code here

}

You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.)

class InnerOne{

public static double methoda() {return d1;}

}

public class InnerOne{

static double methoda() {return d1;}

}

private class InnerOne{

double methoda() {return d1;}

}

static class InnerOne{

protected double methoda() {return d1;}

}

abstract class InnerOne{

public abstract double methoda();

}

3. Given:

public class X {

public void m(Object x) {

x = new Integer(99);

Integer y = (Integer)x;

y = null;

System.out.println("x is" + x);

}

}

When is the Integer object, created in line 3, eligible for garbage collection?

never

just after line 4

just after line 5

just after line 6 (that is, as the method returns)

when the calling method sets the argument it passed into this method to null

4. Which is a valid identifier?

false

default

_object

a-class

5. Which two are equivalent? (Choose two.)

12>4

12/4

12*4

12>>2

12/2^2

12>>>1

6. Which two demonstrate a "has a" relationship? (Choose two.)

public interface Person{ }

public class Employee extends Person{ }

public interface Shape{ }

public interface Rectangle extends Shape{ }

public interface Colorable{ }

public class Shape implements Colorable{ }

public class Species{ }

public class Animal{private Species species;}

interface Component{ }

class Container implements Component{

private Component[] children;

}

7. Given

double pi = Math.PI;

Which two are valid ways to round pi to an int?(Choose two.)

int p = pi;

int p = Math.round(pi);

int p = (int)Math.round(pi);

int p = (int)Math.min(pi + 0.5d);

int p = (int)Math.floor(pi + 0.5d);

8. Which two statements are true for the class java.util.TreeSet? (Choose two.)

The elements in the collection are ordered.

The collection is guaranteed to be immutable.

The elements in the collection are guaranteed to be unique.

The elements in the collection are accessed using a unique key.

The elements in the collection are guaranteed to be synchronized

Return to the top

SUN CERTIFIED PROGRAMMER FOR THE JAVA PLATFORM, JDK 1.1

Note: The certification exam for the jdk 1.1 will be retired January 31, 2001. If you plan to pursue this certification you will need to register by this date. As of February 1, 2001, Sun will only offer certification exams for the Java 2 Platform.

The following samples will help you understand the types of questions you can expect to see when taking the Certified Programmer for the Java Platform, JDK 1.1 examination: Prometric exam number 310-022 (number 310-023 for IBM candidates).

1. Which code fragments would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?

int count = args.length;

int count = args.length - 1;

int count = 0; while (args[count] != null) count ++;

int count=0; while (!(args[count].equals(""))) count ++;

2. Which are keywords in Java (select all that apply)?

sizeof

abstract

native

NULL

BOOLEAN

3. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java on a system with a case-significant file system. Select all that apply.

public class Fred {

public int x = 0;

public Fred (int x) {

this.x = x;

}

}

public class fred

public int x = 0;

public fred (int x) {

this.x = x;

}

}

public class Fred extends MyBaseClass, MyOtherBaseClass {

public int x = 0;

public Fred (int xval) {

x = xval;

}

}

protected class Fred {

private int x = 0;

private Fred (int xval) {

x = xval;

}

}

import java.awt.*;

public class Fred extends Object {

int x;

private Fred (int xval) {

x = xval;

}

}

4. A class design requires that a particular member variable must beaccessible for direct access by any subclasses of this class, but otherwise not by classes which are not members of the same package. What should be done to achieve this?

The variable should be marked public

The variable should be marked private

The variable should be marked protected

The variable should have no special access modifier

The variable should be marked private and an accessor method provided

5. Which correctly creates an array of five empty Strings (select all that apply)?

String a [ ] = new String [5]; for (int i = 0; i < 5; a[i++] = "");

String a [ ] = {"", "", "", "", ""};

String a [5];

String [ ] a = new String [5]; for (int i = 0; i < 5; a[i++] = null);

String [5] a;

6. Which cannot be added to a Container?

an Applet

a Component

a Container

a Menu

a Panel

SUN CERTIFIED PROGRAMMER FOR THE JAVA 2 PLATFORM

Sun Educational Services provides sample questions as a means for cand idates to understand the types of questions that you can expect when taking the Sun Certified Programmer for the Java™ 2 Platform exa mination: Prometric exam number 310-025.

1. Given:

public class ArrayTest {

public static void main (String[] args) {

Object[] ov;

String[] sa = { "Green", "Blue", "Red" };

ov = sa;

System.out.println("Color = " + ov[1]);

}

}

What is the result?

fails to compile

prints Color=Blue

prints Color=Green

generates an exception at runtime

2. Given:

public class OuterClass {

private double d1 = 1.0;

//insert code here

}

You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.)

class InnerOne{

public static double methoda() {return d1;}

}

public class InnerOne{

static double methoda() {return d1;}

}

private class InnerOne{

double methoda() {return d1;}

}

static class InnerOne{

protected double methoda() {return d1;}

}

abstract class InnerOne{

public abstract double methoda();

}

3. Given:

public class X {

public void m(Object x) {

x = new Integer(99);

Integer y = (Integer)x;

y = null;

System.out.println("x is" + x);

}

}

When is the Integer object, created in line 3, eligible for garbage collection?

never

just after line 4

just after line 5

just after line 6 (that is, as the method returns)

when the calling method sets the argument it passed into this method to null

4. Which is a valid identifier?

false

default

_object

a-class

5. Which two are equivalent? (Choose two.)

12>4

12/4

12*4

12>>2

12/2^2

12>>>1

6. Which two demonstrate a "has a" relationship? (Choose two.)

public interface Person{ }

public class Employee extends Person{ }

public interface Shape{ }

public interface Rectangle extends Shape{ }

public interface Colorable{ }

public class Shape implements Colorable{ }

public class Species{ }

public class Animal{private Species species;}

interface Component{ }

class Container implements Component{

private Component[] children;

}

7. Given

double pi = Math.PI;

Which two are valid ways to round pi to an int?(Choose two.)

int p = pi;

int p = Math.round(pi);

int p = (int)Math.round(pi);

int p = (int)Math.min(pi + 0.5d);

int p = (int)Math.floor(pi + 0.5d);

8. Which two statements are true for the class java.util.TreeSet? (Choo se two.)

The elements in the collection are ordered.

The collection is guaranteed to be immutable.

The elements in the collection are guaranteed to be unique.

The elements in the collection are accessed using a unique key.

The elements in the collection are guaranteed to be synchronized

Return to the top

SUN CERTIFIED PROGRAMMER FOR THE JAVA PLATFORM, JDK 1.1

Note: The certification exam for the jdk 1.1 will be retired January 31, 2001. If you plan to pursue this certification you will need to register by this date. As of February 1, 2001, Sun will only offer certification exams for the Java 2 Platform.

The following samples will help you understand the types of questions you can expect to see when taking the Certified Programmer for the Java Platform, JDK 1.1 examination: Prometric exam number 310-022 (number 310-023 for IBM candidates).

1. Which code fragments would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?

int count = args.length;

int count = args.length - 1;

int count = 0; while (args[count] != null) count ++;

int count=0; while (!(args[count].equals(""))) count ++;

2. Which are keywords in Solaris (select all that apply)?

sizeof

abstract

native

NULL

BOOLEAN

3. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java on a system with a case-significant file system. Select all that apply.

public class Fred {

public int x = 0;

public Fred (int x) {

this.x = x;

}

}

public class fred

public int x = 0;

public fred (int x) {

this.x = x;

}

}

public class Fred extends MyBaseClass, MyOtherBaseClass {

public int x = 0;

public Fred (int xval) {

x = xval;

}

}

protected class Fred {

private int x = 0;

private Fred (int xval) {

x = xval;

}

}

import java.awt.*;

public class Fred extends Object {

int x;

private Fred (int xval) {

x = xval;

}

}

4. A class design requires that a particular member variable must beaccessible for direct access by any subclasses of this class, but otherwise not by classes which are not members of the same package. What should be done to achieve this?

The variable should be marked public

The variable should be marked private

The variable should be marked protected

The variable should have no special access modifier

The variable should be marked private and an accessor method provided

5. Which correctly creates an array of five empty Strings (select all that apply)?

String a [ ] = new String [5]; for (int i = 0; i < 5; a[i++] = "");

String a [ ] = {"", "", "", "", ""};

String a [5];

String [ ] a = new String [5]; for (int i = 0; i < 5; a[i++] = null);

String [5] a;

6. Which cannot be added to a Container?

an Applet

a Component

a Container

a Menu

a Panel

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有