A、 -1 B、2 C、1 D、3
12.有以下程序片段,下列哪个选项不能插入到行1。(D ) 1.
2 .public class Interesting{ 3. //do sth 4.}
A、import java.awt.*; B、package mypackage; C、class OtherClass{ } D、public class MyClass{ }
15.在编写Java Applet程序时,需在程序的开头写上( B )语句。 A、import java.awt.* ; B、import java.applet.Applet ; C、import java.io.*; D、import java.awt.Graphics ; 16.类Parent、Child定义如下: 1. publicclass Parent
2.{ public float aFun(float a, float b) throws 3. IOException { } 4.}
5.public class Child extends Parent{ 6. 7.}
将以下哪种方法插入行6是不合法的。( A) A、float aFun(float a, float b){ }
B、public int aFun(int a, int b)throws Exception{ } C、public float aFun(float p, float q){ }
D、public int aFun(int a, int b)throws IOException{ }
17.在使用interface声明一个接口时,只可以使用(D )修饰符修饰该接口。
A、private B、protected C、private protected D、public 18、有以下方法的定义,请选择该方法的返回类型(D )。 ReturnType method(byte x, double y) {
return (short) x/y*2; }
A、byte B、short C、int D、double 三.程序阅读题
1.以下程序的输出结果为 相等 。 class StringTest1 {
public static void main(String[] args) {
String s1=\
String s2=newString(\if(s1.equals(s2)){
System.out.println(\相等\}else{
System.out.println(\不相等\} } }
2.以下程序段的输出结果为 5 6 7 8 9 。 public class TestArray {
public static void main(String args[ ]){ int i , j ;
int a[ ] = { 5,9,6,8,7};
for (i = 0 ; i < a.length-1; i ++ ) { int k = i;