站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Java 专题Sun认证Java程序员考试(JDK1.1)样题

Sun认证Java程序员考试(JDK1.1)样题

摘要: Sun认证Java程序员考试(JDK1.1)样题



以下试题可帮您了解考试310-022 (IBM考生为310-023)的题型。

注意:正确答案为黑体字。

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 ++;
Which are keywords in Java?
sizeof
abstract
native
NULL
BOOLEAN


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.
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;
}
}
A class design requires that a particular member variable must be accessible 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


Which correctly create an array of five empty Strings?
String a [] = new String [5];
for (int i = 0; i < 5; a[i++] = "");
String a [] = {"", "", "", "", ""};
String a [5];
String [5] a;
String [] a = new String [5];
for (int i = 0; i < 5; a[i++] = null);
Which cannot be added to a Container?
an Applet
a Component
a Container
a Menu
a Panel
↑返回目录
前一篇: 怎样设计合适的接口
后一篇: Sun认证Java程序员考试(JDK1.1)简介