当前位置:首页 > S1 - JavaPen Text - Finishing
C) System.out.print(list.toString()); D) System.out.print(list.get(0));
144、 给定Java代码如下:
public class Test {
static int i;
public int aMethod() { i++; return i; }
public static void main(String[] args) { Test test=new Test(); test.aMethod();
System.out.println(test.aMethod()); } }
编译运行后,输出结果是()。(选择一项) A) 0 B) 1 C) 2 D) 3
145、 Java语言中有如下代码:
switch(x) {
case 100:
System.out.println(“100”); break; case 110:
System.out.println(“110”); break; }
下列x的定义中,可是使上段代码输出100的有()。(选择二项)A) byte x=100; B) float x=100; C) char x=?d?;
146、 给定一个Java程序的代码片段如下:
String s=“ hello,world”; System.out.println(A);
运行后,要输出字符串world,则A处应该填入()。(选择二项)A) s.substring(s.indexOf(“w”),s.length()) B) s.substring(s.charAt(“w”),s.length()) C) s.substring(6,11) D) s.substring(7,12)
147、 在Java中,以下定义数组的语句正确的是()。(选择一项)
A) int t[10]=new int[]; B) char a[]=“hefg”; C) int t[]=new int[10]; D) double d=new double[10];
148、 Java中,要使用输入输出流,必须导入()包。(选择一项)
D) long x=100; 25
A) java.lang B) java.stream C) java.net D) java.io
149、 在Java中,已定义两个接口B和C,要定义一个实现这两个接口的类,以下语句正
确的是()。(选择一项) A) interface A extends B,C B) interface A implements B,C C) class A implements B,C D) class A implements B,implements C
150、 给定一个Java程序的代码片段如下:
char c=?a?; int i=c; float f=i++;
byte b=(byte)(f+1);()
System.out.println(c+“,”+i+“,”+f+“,”+b); 编译运行后的输出结果是()。(选择一项) A) a,97,97.0,98 B) a,97,97,98 C) a,98,97.0,98 D) a,98,97,98
151、 给定一个Java程序的代码片段如下:
String s=“hello,world”; s.replace(?,?, ? ?);
System.out.println(s);
运行后,正确的输出结果是()。(选择一项) A) hello world B) hello,world C) HELLO WORLD D) HELLO,WORLD
152、 给定Java代码如下:
public class Test extends Parent {
public int count() { return 1%9; }
public static void main(String[] args) { System.out.println(count()); } }
编译运行,结果是()。(选择一项) A) 编译错误 B) 运行时出现例外 C) 正常运行,输出1 D) 正常运行,输出0
153、 在Java中,下列()方法可以把JFrame对象jFrame的布局管理器设为FlowLayout
类型。(选择一项)
A) jFrame.setLayout(new FlowLayout()); B) jFrame.addLayout(new FlowLayout()); C) jFrame.setFlowLayout(); D) jFrame.addFlowLayout();
26
154、 在Java中,()对象可以使用键/值的形式保存数据。(选择一项)
A) ArrayList B) HashSet C) HashMap D) LinkedList
155、 给定如下Java代码,编译运行之后,将会输出()。(选择一项)
public class Test {
public static void main(String[] args) { int a=5;
System.out.println((a%2==1)?(a+1)/2:a/2); } } A) 1 B) 2 C) 3 D) 4
156、 给定如下Java代码,编译时会在()出现错误。(选择一项)
class Parent { }
class Child extends Parent {
public static void main(String[] args) { Parent p1=new Child(); //第一行 Parent p2=new Parent(); //第二行 Child c1=new Child(); //第三行 Child c2=new Parent(); //第四行 } }
A) 第一行 B) 第二行 C) 第三行 D) 第四行
157、 给定如下Java代码:
public class Test {
public static void main(String[] args) { int output=10; boolean b1=false;
if ((b1==true)&&((output+=10)==20)) { System.out.println(“Equal ”+output);
} else {
System.out.println(“Not equal ”+output); } } }
编译运行后,将会输出()。(选择一项) A) Equal 10 B) Equal 20 C) Not equal 10 D) Not equal 20
158、 给定Java代码,如下:
abstract class Shape {
27
abstract void draw(); }
要创建Shape类的子类Circle,以下代码正确的是()。(选择二项) A) class Circle extends Shape {
int draw() {} }
B) abstract class Circle extends Shape { }
C) class Circle extends Shape { void draw(); }
D) class Circle extends Shape { void draw() {} }
159、 给定如下Java代码,在下划线处填入(),代表HelloWorld类具有main方法,可以
独立运行。(选择一项) public class HelloWorld {
{
System.out.println(“hello world”);
} }
A) public static void main(String args) B) static void main(String args[]) C) public static void main(String[] strs) D) public static main(String args[])
160、 要编写一个Swing应用程序,必须导入()包。(选择一项)
A) javax.swing B) java.swing C) javax.awt D) java.awt.event
161、 在Java语言中,以下()代码会引起编译期错误。(选择二项)
A) float[] f1=new float[]; B) float[] f2=new float[3]; C) float f3[]={1.0,2.0,3.0}; D) float f4[]=new float[]{1.0f,2.0f,3.0f};
162、 给定如下Java代码:
class Parent {
protected void eat(){} }
class Child extends Parent { void eat(){} }
以下()修饰符可以填入下划线处。(选择二项) A) protected B) private C) 什么也不填 D) public
163、 在Java中,以下初始化字符串的语句中,错误的是()。(选择一项)
A) StringBuffer sb1=“abcd”; B) StringBuffer sb2=new StringBuffer(“abcd”);
28
共分享92篇相关文档