文档库 最新最全的文档下载
当前位置:文档库 › JAVA认证:78道SCJP考试试题精解

JAVA认证:78道SCJP考试试题精解

JAVA认证:78道SCJP考试试题精解
JAVA认证:78道SCJP考试试题精解

QUESTION NO: 70

Which statement about static inner classes is true?

A. An anonymous class can be declared as static.

B. A static inner class cannot be a static member of the outer class.

C. A static inner class does not require an instance of the enclosing class.

D. Instance members of a static inner class can be referenced using the class name of the

static inner

class.

Answer: C

QUESTION NO: 71

Exhibit:

1. class A {

2. public byte getNumber () {

3. return 1;

4. }

5. }

6.

7. class B extends A {

8. public short getNumber() {

9. return 2;

10. }

11.

12. public static void main (String args[]) {

13. B b = new B ();

14. System.out.printIn(b.getNumber())

15. }

16. }

What is the result?

A. Compilation succeeds and 1 is printed.

B. Compilation succeeds and 2 is printed.

C. An error at line 8 causes compilation to fail.

D. An error at line 14 causes compilation to fail.

E. Compilation succeeds but an exception is thrown at line 14.

Answer: C

QUESTION NO: 72

Given:

AnInterface is an interface.

AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that

takes one int argument.

Which two construct an anonymous inner class? (Choose Two)

F. AnAdapter1 aa=new AnAdapter1(){}

G. AnAdapter0 aa=new AnAdapter0(){}

H. AnAdapter0 aa=new AnAdapter0(5){}

I. AnAdapter1 aa=new AnAdapter1(5){}

J. AnInterface a1=new AnInterface(5){}

Answer: B, D

QUESTION NO: 73

Which two statements are true? (Choose Two)

A. An inner class may be declared as static.

B. An anonymous inner class can be declared as public.

C. An anonymous inner class can be declared as private.

D. An anonymous inner class can extend an abstract class.

E. An anonymous inner class can be declared as protected.

Answer: A, D

QUESTION NO: 74

Exhibit:

1. public class Mycircle {

2. public double radius;

3. public double diameter;

4.

5. public void setRadius(double radius)

6. this.radius = radius;

7. this.diameter= radius * 2;

8. }

9.

10. public double getRadius() {

11. return radius;

12. }

13. }

Which statement is true?

A. The Mycircle class is fully encapsulated.

B. The diameter of a given MyCircle is guaranteed to be twice its radius.

C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation.

D. The radius of a MyCircle object can be set without affecting its diameter.

Answer: B

QUESTION NO: 75

You want to limit access to a method of a public class to members of the same class. Which access

modifier accomplishes this objective?

A. Public

B. Private

C. Protected

D. Transient

E. No access modifier is required

Answer: B

QUESTION NO: 76

Exhibit:

ClassOne.java

1. package com.abc.pkg1;

2. public class ClassOne {

3. private char var = …a';

4. char getVar() {return var;}

5. }

ClassTest.java

1. package com.abc.pkg2;

2. import com.abc.pkg1.ClassOne;

3. public class ClassTest extends ClassOne {

4. public static void main(String[]args) {

5. char a = new ClassOne().getVar();

6. char b = new ClassTest().getVar();

7. }

8. }

What is the result?

A. Compilation will fail.

B. Compilation succeeds and no exceptions are thrown.

C. Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.

D. Compilation succeeds but an exception is thrown at line 6 in ClassTest.java. Answer: B

QUESTION NO: 77

Given:

1. public class ArrayTest {

2. public static void main (String[]args) {

3. float f1[], f2[];

4. f1 = new float [10];

5. f2 = f1;

6. System.out.printIn (“f2[0]=” + f2[0]);

7. }

8. }

What is the result?

A. It prints f2[0] = 0.0

B. It prints f2[0] = NaN

C. An error at line 5 causes compile to fail.

D. An error at line 6 causes compile to fail.

E. An error at line 6 causes an exception at runtime.

Answer: A

QUESTION NO: 78

Which two statements are true regarding the creation of a default constructor? (Choose Two)

A. The default constructor initializes method variables.

B. The compiler always creates a default constructor for every class.

C. The default constructor invokes the no-parameter constructor of the superclass.

D. The default constructor initializes the instance variables declared in the class.

E. When a class has only constructors with parameters, the compiler does not create a default

constructor.

Answer: D, E

QUESTION NO: 79

Exhibit:

1. class super {

2. public int getLength() {return 4;}

3. }

4.

5. public class Sub extends Super {

6. public long getLength() {return 5;}

7.

8. public static void main (String[]args) {

9. super sooper = new Super ();

10. Sub sub = new Sub();

11. System.out.printIn(

12. soop er.getLength()+ “,” + sub.getLength() };

13. }

14. }

What is the output?

A. 4, 4

B. 4, 5

C. 5, 4

D. 5, 5

E. The code will not compile.

Answer: E

QUESTION NO: 80

Given:

1. public abstract class Test {

2. public abstract void methodA();

3.

4. public abstract void methodB()

5. {

6. System.out.printIn(“Hello”);

7. }

8. }

Which three changes (made independently) allow the code to compile? (Choose Three)

A. Add a method body to methodA.

B. Replace lines 5-7 with a semic olon (“.”)

C. Remove the abstract qualifier from the declaration of Test.

D. Remove the abstract qualifier from the declaration of methodB.

E. Remove the abstract qualifier from the declaration of methodA.

F. Remove methodB in its entirely and change class o interface in line 1.

Answer: B, D, F

QUESTION NO: 81

Which determines if “prefs” is a directory and exists on the file system?

A. Boolean exists=Directory.exists (“prefs”);

B. Boolean exists=(new File(“prefs”)).isDir();

C. Boolean ex ists=(new Directory(“prefs”)).exists();

D. Boolean exists=(new File(“prefs”)).isDirectory();

E. Boolean exists=true;

Try{

Directory d = new Directory(“prefs”);

}

catch (FileNotFoundException e) {

exists = false;

}

Answer: D

QUESTION NO: 82

Which two create an InputStream and open file the “file.txt” for reading? (Choose Two)

A. InputStream in=new FileReader(“file.txt”);

B. InputStream in=new FileInputStream(“file.txt”);

C. InputStream in=new InputStreamFileReader (“file.txt”, “read”);

D. FileInputStream in=new FileReader(new File(“file.txt”));

E. FileInputStream in=new FileInputStream(new File(“file.txt”));

Answer: B, E

QUESTION NO 83

Which two construct an OutputSream that appends to the file “file.txt”? (Choose Two)

A. OutputStream out=new FileOutputStream(“file.txt”);

B. OutputStream out=new FileOutputStream(“file.txt”, “append”);

C. FileOutputStream out=new FileOutputStream(“file.txt”, true);

D. FileOutputStream out=new FileOutputStream(new file(“file.txt”));

E. OutputStream out=new FileOutputStream(new File(“file.txt”)true);

Answer: C, E

QUESTION NO: 84

Which constructs a BufferedIputStream?

A. New BufferedInputStream(“in.txt”);

B. New BufferedInputStream(new File(“in.txt”));

C. New BufferedInput Stream(new Writer(“in.txt”));

D. New BufferedInputStream(new Writer(“in.txt”));

E. New BufferedInputStream(new InputStream(“in.txt”));

F. New BufferedInputStream(new FileInputStream(“in.txt”)); Answer: F

QUESTION NO: 85

Which is a valid identifier?

A. false

B. default

C. _object

D. a-class

Answer: C

QUESTION NO: 86

Exhibit:

1. package foo;

2.

3. import java.util.Vector;

4.

5. private class MyVector extends Vector {

6. int i = 1;

7. public MyVector() {

8. i = 2;

9. }

10. }

11.

12. public class MyNewVector extends MyVector {

13. public MyNewVector () {

14. i = 4;

15. }

16. public static void main (String args []) {

17. MyVector v = new MyNewVector();

18. }

19. }

The file MyNewVector.java is shown in the exhibit. What is the result?

A. Compilation will succeed.

B. Compilation will fail at line 5.

C. Compilation will fail at line 6.

D. Compilation will fail at line 14.

E. Compilation will fail at line 17.

Answer: B

QUESTION NO: 87

Given:

1. public class Test {

2. public static void main (String[]args) {

3. String foo = args[1];

4. String bar = args[2];

5. String baz = args[3];

6. System.out.printIn(“baz = ” + baz);

7. }

8. }

And the output:

Baz = 2

Which command line invocation will produce the output?

A. Java Test 2222

B. Java Test 1 2 3 4

C. Java Test 4 2 4 2

D. Java Test 4 3 2 1

Answer: C

QUESTION NO: 88

Given:

8. int index = 1;

9. String [] test = new String[3];

10. String foo = test[index];

What is the result?

E. Foo has the value “”

B. Foo has the value null

C. An exception is thrown

D. The code will not compile

Answer: B

QUESTION NO: 89

Given:

1. public interface Foo{

2. int k = 4;

3. }

Which three are equivalent to line 2? (Choose Three)

A. Final int k = 4;

B. Public int k = 4;

C. Static int k = 4;

D. Private int k = 4;

E. Abstract int k = 4;

F. Volatile int k = 4;

G. Transient int k = 4;

H. Protected int k = 4;

Answer: A, B, C

QUESTION NO: 90

Given:

310-025

Leading the way in IT testing and certification tools, https://www.wendangku.net/doc/3317999280.html,

- 48 -

1. public class foo {

2. static String s;

3. public static void main (String[]args) {

4. system.out.printIn (“s=” + s);

5. }

6. }

What is the result?

A. The code compiles and “s=” is printed.

B. The code compiles and “s=null” is printed.

C. The code does not compile because string s is not initialized.

D. The code does not compile because string s cannot be referenced.

E. The code compiles, but a NullPointerException is thrown when toString is called. Answer: B

QUESTION NO: 91

Which two valid declarations of a char? (Choose Two)

A. Char ch = “a”;

B. Char ch = …\' …;

C. Char ch = …cafe';

D. Char ch = “cafe”;

E. Char c h = …\ucafe';

F. Char ch = …\u10100';

G. Char ch = (char) true;

Answer: B, E

310-025

Leading the way in IT testing and certification tools,

QUESTION NO: 92

Given:

1. String foo = “blue”;

2. Boolean[]bar = new Boolean [1];

3. if (bar[0]) {

4. foo = “green”;

5. }

What is the result?

A. Foo has the value of “”

B. Foo has the value of null.

C. Foo has the value of “blue”

D. Foo has the value of “green”

E. An exception is thrown.

F. The code will not compile.

Answer: F

QUESTION NO: 93

Exhibit:

1. public class X {

2. public static void main (String[]args) {

3. String s1 = new String (“true”);

4. Boolean b1 = new Boolean (true);

5. if (s2.equals(b1)) {

6. System.out.printIn(“Equal”);

7. }

8. }

9. }

What is the result?

A. The program runs and prints nothing.

B. The program runs and prints “Equal”

C. An error at line 5 causes compilation to fail.

D. The program runs but aborts with an exception. Answer: A

QUESTION NO: 94

Given:

1. public class Foo {

2. public static void main (String []args) {

3. int i = 1;

4. int j = i++;

5. if ((i>++j) &&(i++ ==j)) {

6. i +=j;

7. }

8. }

9. }

What is the final value of i?

A. 1

B. 2

C. 3

D. 4

E. 5

Answer: B

QUESTION NO: 95

Exhibit:

1. public class X {

2. public static void main (String[]args) {

3. string s = new string (“Hello”);

4. modify(s);

5. System.out.printIn(s);

6. }

7.

8. public static void modify (String s) {

9. s += “world!”;

10. }

11. }

What is the result?

E. The program runs and prints “Hello”

F. An error causes compilation to fail.

G. The program runs and prints “Hello world!”

H. The program runs but aborts with an exception. Answer: A

QUESTION NO: 96

Which two are equivalent? (Choose Two)

A. 16>4

B. 16/2

C. 16*4

D. 16>>2

E. 16/2^2

F. 16>>>2

Answer: D, F

QUESTION NO: 97

Exhibit:

1. public class X {

2. public static void main (String[]args) {

3. int [] a = new int [1]

4. modify(a);

5. System.out.printIn(a[0]);

6. }

7.

8. public static void modify (int[] a) {

9. a[0] ++;

10. }

11. }

What is the result?

A. The program runs and prints “0”

B. The program runs and prints “1”

C. The program runs but aborts with an exception.

D. An erro r “possible undefined variable” at line 4 causes compilation to fail.

E. An error “possible undefined variable” at line 9 causes compilation to fail. Answer: B

QUESTION NO: 98

Given:

13. public class Foo {

14. public static void main (String [] args) {

15. StringBuffer a = new StringBuffer (“A”);

16. StringBuffer b = new StringBuffer (“B”);

17. operate (a,b);

18. system.out.printIn{a + “,” +b};

19. )

20. static void operate (StringBuffer x, StringBuffer y) {

21. y.append {x};

22. y = x;

23. )

24. }

What is the result?

A. The code compiles and prints “A,B”.

B. The code compiles and prints “A, BA”.

C. The code compiles and prints “AB, B”.

D. The code compiles and prints “AB, AB”.

E. The code compiles and prints “BA, BA”.

F. The code does not compile because “+” cannot be overloaded for stringBuffer. Answer: B

QUESTION NO: 99

Given:

1. public class X {

2. public static void main (String[] args) {

3. byte b = 127;

4. byte c = 126;

5. byte d = b + c;

6. }

7. }

Which statement is true?

A. Compilation succeeds and d takes the value 253.

B. Line 5 contains an error that prevents compilation.

C. Line 5 throws an exception indicating “Out of range”

D. Line 3 and 4 contain error that prevent compilation.

E. The compilation succeeds and d takes the value of 1. Answer: B

QUESTION NO: 100

Given:

1. public class WhileFoo {

2. public static void main (String []args) {

3. int x= 1, y = 6;

4. while (y--) {x--;}

5. system.out.printIn(“x=” + x “y =” + y);

6. }

7. }

What is the result?

A. The output is x = 6 y = 0

B. The output is x = 7 y = 0

C. The output is x = 6 y = -1

D. The output is x = 7 y = -1

E. Compilation will fail.

Answer: E

QUESTION NO: 101

Which statement is true?

A. The Error class is a untimeException.

B. No exceptions are subclasses of Error.

C. Any statement that may throw an Error must be enclosed in a try block.

D. Any statement that may throw an Exception must be enclosed in a try block.

E. Any statement that may thro a runtimeException must be enclosed in a try block. Answer: D

QUESTION NO: 102

Exhibit:

1. int I=1, j=0

2.

3. switch(i) {

4. case 2:

5. j+=6;

6.

7. case 4:

8. j+=1;

9.

10. default:

11. j +=2;

12.

13. case 0:

14. j +=4;

15. }

16.

What is the value of j at line 16?

A. 0

B. 1

C. 2

D. 4

E. 6

Answer: AE

QUESTION NO: 103

Given:

1. switch (i) {

2. default:

3. System.out.printIn(“Hello”);

4. )

What is the acceptable type for the variable i?

A. Byte

B. Long

C. Float

D. Double

E. Object

F. A and B

G. C and D

Answer: A

QUESTION NO: 104

You need to store elements in a collection that guarantees that no duplicates are stored. Which two

interfaces provide that capability? (Choose Two)

A. Java.util.Map

B. Java.util.Set

C. Java.util.List

D. Java.util.StoredSet

E. Java.util.StoredMap

F. Java.util.Collection

Answer: B, D

QUESTION NO: 105

Which statement is true for the class java.util.ArrayList?

A. The elements in the collection are ordered.

B. The collection is guaranteed to be immutable.

C. The elements in the collection are guaranteed to be unique.

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

E. The elements in the collections are guaranteed to be synchronized.

Answer: A

QUESTION NO: 106

Exhibit:

1. public class X implements Runnable(

2. private int x;

3. private int y;

4.

5. public static void main(String[]args)

6. X that = new X();

7. (new Thread(that)).start();

8. (new Thread(that)).start();

9. )

10.

11. public void run() (

12. for (;;) (

13. x++;

14. y++;

15. System.out.printIn(“x=” + x + “, y = ” + y);

16. )

17. )

18. )

What is the result?

A. Errors at lines 7 and 8 cause compilation to fail.

B. The program prints pairs of values for x and y that might not always be the same on the same line

(for example, “x=2, y=1”).

C. The program prints pairs of values for x and y that are always the same on the same line (for

example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1”followed by

“x=1, y=1”).

D. The program prints pairs of values for x and y that are always the same on the same line (for

example, “x=1, y=1”. In addition, each value appears only for once (for example, “x=1,

y=1”

followed by “x=2, y=2”).

Answer: D

QUESTION NO: 107

Given:

1. public class SyncTest {

2. private int x;

3. private int y;

4. public synchronized void setX (int i) (x=1;)

5. public synchronized void setY (int i) (y=1;)

6. public synchronized void setXY(int 1)(set X(i); setY(i);)

7. public synchronized Boolean check() (return x !=y;)

8. )

Under which conditions will check () return true when called from a different class?

A. Check() can never return true.

B. Check() can return true when setXY is called by multiple threads.

C. Check() can return true when multiple threads call setX and setY separately.

D. Check() can only return true if SyncTest is changed to allow x and y to be set separately.

Answer: A

QUESTION NO: 108

java小试题

1. 关于Java语言的特征,描述正确的是 A. 支持跨平台(Windows,Linux,Unix等) B. GC(自动垃圾回收),提高了代码安全性 C. 支持类似C的指针运算操作 D. java语言是面向对象的语言 解答:ABD 范围:corejava 难度:3 2.下列表达式正确的是 A. byte b=128; B. boolean b=null; C. long a = 2147483648L; D. float f=0.9239; 解答:C 3.下列不属于java标识符的是 A.HelloWorld B._HelloWorld C. $HelloWorld D. HelloWorld3 E. 3HelloWorld 解答:E 4. 下列代码的运行结果是: public class SwitchTest { public static void main (String []args) { System.out.println (“value =” +switchIt(4)); } public static int switchIt(int x) { int j = 1; switch (x) { case 1: j++;

case 2: j++; case 3: j++; case 4: j++; case 5: j++; default:j++; } return j + x; } } A. Value =3 B. Value =4 C. Value =5 D. Value =6 E. Value =7 F. Value =8 解答:F 5. 以下程序的输出结果为: public class test { public static void main(String args[]) { int x=1,y=1,z=1; if (x--==1&&y++==1||z++==1) System.out.println("x="+x+",y="+y+",z="+z); } } A. x=0,y=2,z=1 B. x=1,y=2,z=1 C. x=0,y=1,z=1 D. x=0,y=2,z=2 解答:A #6. 下面的程序没有编译错误的是:

JAVA期末考试试卷

天津城市建设学院2007~2008学年第二学期 《 java 语言程序设计A 》 试题A 卷 课程号:073101-0 试卷说明:闭卷考试,时间120分钟。 一、 填空(本题共15空,每空2分,共30分) 1.如果一个java 源程序文件中定义有4个类,使用sun 公司的JDK 编译器javac 编译该源程序文件将产生_____4___个文件名与类名相同扩展名为___.Class_____的字节码文件。 2.Java 中所有类都是类 __Object__的子类。 3.请填出在java .lang 包中与下列基本数据类型相对应的封装类: float :java .lang .Float , char : _ java .Lang.char_______, boolean : ___ java .Lang.boolean_____。 4.被关键字____final______修饰的方法是不能被当前类的子类重新定义的方法 5.线程的四种状态是__新建_____ 、_运行_ 、_中断 、__死亡___。 6.java 语言中__https://www.wendangku.net/doc/3317999280.html,ng.Objet ___是所有类的根。 7.Swing 的事件处理机制包括__事件的监听者__、事件和事件处理者。 8.URL_____Uniform Resourse Locator_____是的缩写。 9.java 有两类应用程序java Application 和____java 10.转义字符以___\__开头。 二、选择(本题共20小题,每题2分,共40分) 1.欲构造ArrayList 类的一个实例,此类继承了List 接口,下列哪个方法是正确的 ? ( B ) A 、 ArrayList myList=new Object (); B 、 List myList=new ArrayList (); C 、 ArrayList myList=new List (); D 、 List myList=new List (); 2.paint()方法使用哪种类型的参数? ( A ) A 、 Graphics B 、 Graphics2D C 、 String D 、 Color 3.指出正确的表达式 ( C ) A 、 byte=128; B 、 Boolean=null; C 、 long l=0xfffL; D 、 double=0.9239d; 4.指出下列程序运行的结果 ( B ) public class Example{ String str=new String("good"); char[]ch={'a','b','c'}; public static void main(String args[]){ Example ex=new Example(); ex .change(ex .str,ex .ch); System .out .print(ex .str+" and "); Sytem .out .print(ex .ch); } public void change(String str,char ch[]){ str="test ok"; ch[0]='g'; } } B 、 good and abc B 、 good and gbc C 、test ok and abc D 、 test ok and gbc 5.运行下列程序, 会产生什么结果 ( A )

面向对象试题(标准答案)

CoreJavaOOP考试题 考试时间:90分钟 考试总分:100分 一、选择题(不定项选择)(22*4=88) 1. 类A,B的定义如下: class A { private int a = 100; A() { System.out.print("A()"); System.out.println(a); } } class B extends A { private int a = 200; B() { System.out.print("B()"); System.out.println(a); } } 运行下面的代码: new B(); 输出的结果是:(A )。 A. A() 100 B() 200 B. A() 200 B() 200 C. B() 200 A() 100 D. B() 200 A() 200

2.下列说法正确的是(D ) A.所有类都必须定义构造方法(构造器) B.构造方法必须初始化类的所有数据成员 C.子类定义了构造器后,不再调用父类的构造器 D.构造方法可以访问类的非静态成员 3.在Java中,哪个关键字使类不能派生子类?, (A ) A : final B : public C : private D : native 4.class Base{ static void test(){ System.out.println(“Base.test()”); } } public class Child extends Base{ static void test(){ System.out.println(“Child.test()”); } public static void main(String[] args){ Base base = new Child(); Child child = new Child(); base.test(); child.test(); } } 程序运行的结果是( C ) A.Child.test() Child.test() B.Child.test() Base.test() C.Base.test() Child.test() D.Base.test() Base.test()

Java期末考试试卷答案A

JAVA程序设计试卷库(第5套) 一、单选题(每小题 2 分,共 20 分) 1、Java Application源程序的主类是指包含有( A )方法的类。 A. main方法 B. toString方法 C. init方法 D. actionPerfromed方法 2、分析下面的程序段,下面的哪个描述是正确的。( B ) char mychar=’c’; switch(mychar){ default: case ‘a’“a”);break; case ‘b’“b”);break; } A.switch语句块是错误的, 因为switch后面的表达式 值的类型不是整数; B.switch语句块是正确的; C.switch语句块是错误的, 因为default没有放在语 句块的最后面; D.代码运行时,没有任何输出 结果。 3、编译并运行下面的Java程序, 将产生( B )结果。 class A{ int var1=1; int var2; public static void main(String[] args){ int var3=3; A a=new A(); } } A. 0 B. 4 C. 3 D. 代码无法编译,因为var2根本 没有被初始化 4、在Java中,下面关于包的陈述 中正确的是( D )。

A. 包的声明必须是源文件的任意位置; B. 包的声明必须紧跟在import 语句的后面; C. 只有公共类才能放在包中; D. 可以将多个源文件中的类放在同一个包中 5、 在Java 语言中,当一个类的某个变量声明为protected 时下列说法正确的是( C )。 A. 只有同一类中的成员才能访问它; B. 不同包中的任何其他类都能够访问它; C. 同包中的任何其他类能够访问它; D. 不同包中的子类不可以访问该变量。 6、在Java 中,执行下面的语句后,c 的值为( D )。 String s= "Jessica "; char c=s.charAt(6); A. "c " B. "a " C. 'c ' D. 'a ' 7、设有下面两个赋值语句: a = Integer.parseInt(“1024”); b = Integer.valueOf(“1024”).int Value(); 下述说法正确的是( D )。 A .a 是整数类型变量,b 是整数类对象。 B .a 是整数类对象,b 是整数类型变量。 C .a 和b 都是整数类对象并且它们的值相等。 D .a 和b 都是整数类型变量并且它们的值相等。 8、事件剪裁类如WindowAdapter (它实现了WindowListener 接

SunJava程序员认证考试题

第一部分 基础知识练习 目标 本章对应于《学生指南》各章的内容分别提供了练习题集,包括: ●第一章Java入门 ●第二章数据类型和运算符 ●第三章流程控制与数组 ●第四章封装 ●第五章继承 ●第六章抽象类与接口 ●第七章多态 ●第八章异常 ●第九章多线程机制 ●第十章输入输出流 ●第十一章使用泛型和集合框架 ●第十二章基于Swing的图形用户界面(GUI)设计 ●第十三章Java事件驱动编程

第一章练习题(Java入门) 1.下列哪项不是JDK所包含的内容?(选一项)A.Java编程语言 B.工具及工具的API C.Java EE扩展API D.Java平台虚拟机 2.下列关于JDK、JRE和JVM的描述。哪项正确?A.JDK中包含了JRE,JVM中包含了JRE B.JRE中包含了JDK,JDK中包含了JVM C.JRE中包含了JDK,JVM中包含了JRE D.JDK中包含了JRE,JRE中包含了JVM 3.下列哪个工具可以编译java源文件?A.javac B.jdb C.javadoc D.junit 4.JDK工具javadoc的作用是哪项? A.生成Java文档 B.编译Java源文件 C.执行Java类文件

D.测试Java代码 5.以下哪些包是Java标准库中常用的包?(选三项)A.java.lang B.javax.servlet .http C.j ava. io D.java.sql

6.使用JDK工具生成的Java文档的文件格式是? A.XML格式 B.自定义格式 c.二进制格式 D.HTML格式 7.以下关于JVM的叙述,哪项正确?(选两项) A.JVM运行于操作系统之上,它依赖于操作系统 B.JVM运行于操作系统之上,它与操作系统无关 C.JVM支持Java程序运行,它能够直接运行Java字节码文件D.JVM支持Java程序运行,它能够直接运行Java源代码文件 8.以下关于支持Java运行平台的叙述,哪项错误? A.Java可在Solaris平台上运行 B.Java可在Windows平台上运行 C.Java语言与平台无关。Java程序的运行结果依赖于操作系统D.Java语言与平台无关。Java程序的运行结果与操作系统无关 9.以下关于Applet和Java程序之间关系的叙述,哪项错误?A.-个Applet就是一段Java程序 B.Applet是一种特殊的Java程序,它需要运行在Web服务器上C.Applet是一种特殊的Java程序,它需要运行在Web浏览器上

公司内部Javaio流笔试题

公司内部Javaio流笔试题

IO 框架 Key Point * File 类 * 流的分类 * 基本字节流 * 字节过滤流 * 基本字符流、桥转换 * 字符过滤流 * 对象序列化 练习 1. (File 类)以下关于File 类说法正确的是: A.一个File 对象代表了操作系统中的一个文件或者文件夹 B.能够使用File 对象创立和删除一个文件 C.能够使用File 对象创立和删除一个文件夹 D.当一个File 对象被垃圾回收时,系统上对应的文件或文件夹也被删除2. (File 类)有如下代码: public class TestFile{ public static void main(String args[]){ File file = new File(“chp13/corejava.txt”); } } 请选择一个正确答案: A. corejava.txt 文件在系统中被创立 B. 在windows 系统上运行出错,因为路径分隔符不正确 C. corejava.txt 文件在系统中没有被创立

D. 如果corejava.txt 文件已存在,则抛出一个异常 3. (File 类)将下列代码补充完整 class TestMyFile{ public static void main(String args[]) throws Exception{ File file; //创立一个File 对象表示当前目录下的“hello.txt”文件 //判断该文件是否存在 //如果该文件存在,则输出该文件的完整路径 } } 4. (流的分类)对于FileInputStream 来说,从方向上来分,它是_________流,从数据单 位上分,它是__________流,从功能上分,它是____________流。 5. (字节流, FileInputStream)FileInputStream 有三个重载的read 方法,其中 1) 无参的read 方法返回值为___类型,表示_________________ 2) int read(byte[] bs)方法返回值表示______________,参数表示 ________________ 3) int read(byte[] bs, int offset, int len) 方法返回值表示 _______________,参数分别表示 ___________________________。 6. (FileInputStream)下面关于FileInputStream 类型说法正确的是: A.创立FileInputStream 对象是为了读取硬盘上的文件 B.创立FileInputStream 对象时,如果硬盘上对应的文件不存在,则抛出一个异常 C.利用FileInputStream 对象能够创立文件 D.FileInputStream 对象读取文件时,只能读取文本文件。

Java期末考试题

2010年——2011年Java期末考试题 一、判断题。 1.Java语言是平台无关的语言。T 2.类的静态方法中可以访问该类的非静态数据成员.F 3.Java中方法调用时参数传递都是按值传递的,因此从方法中退出时,参数的值是不 会变的。T 4.覆盖方法所抛出的异常不能比原方法更多。T 5.Final 方法不能被覆盖。T 6.抽象类中一定包含抽象方法。F 7.接口中的方法必须是抽象方法。T 8.在方法定义中,所以可能发生的异常都必须用try{} catch(){}捕捉。F 9.Java支持多重继承。F 10.Final修饰的类不能派生子类。T 11.覆盖的同名方法中,子类方法不能比父类方法的访问权限更严格。T 12.不能在静态方法中使用this.T 13.抽象类中不能创建对象。T 14.一个类可以实现多接口。T 15.接口中可以包含非静态成员。F 16.不论是否捕捉到异常try{}catch(){} final{}语句中finally块中的代码总要被执行。T 17.一个类实现一个接口,则该类必须实现接口中的所有方法。F 18.线程使用sleep方法去休眠后可以使用notify方法唤醒。F 19.线程使用sleep方法休眠是会释放该线程同步锁定的对象。F 20.Final类中的属性和方法都必须是final的。F 二、选择题 1、Java中复合数据类型不包括(D) A.类类型 B.数组 C.接口类型 D.指针 2、请从四个选项中选择答案,下列代码的执行结果是:(C) Public class Test{ Public static void main(String args[]){ Float t=9.0f; Int q=6; System.out.println((t++)*(--q)); } } A.40 B.40.0 C.45.0 D.36.0 3、下列关于修饰符混用的说法,错误的是(D) A.abstract 不能与final 并列修饰同一个类 B.abstract类中可以有非abstract的方法 C.普通类(非abstract类)中不能有abstract方法 D.static方法中能处理非static的属性 4、关于被保护访问控制符protected修饰的成员变量,以下说法正确的是(A) A.可以被该类自身、与它在同一个包中的其它类、在其它包中的该类的子类所访问B.只能被该类本身和该类的所有的子类访问 C.只能被该类自身所访问 D.只能被同一个包中的类访问 5、x=2,y=3,z=4,则表达式z*=y++*--x的值是(A) A.12 B.24 C.16 D.3 6、以下赋值语句正确的是(D) A.char c1=”a” B.float f1=3.22 C.byte b1=266 D.long L1=0xAC8L 7、Java不支持多重继承,但我们可以通过(B)实现 A.多态 B.接口 C.覆盖 D.抽象类 8.已知类person是类student的父类,以下数组定义和赋值哪些是正确的(A) A. person p[]=new person[3]; p[1]=new student(); B .student s[]=new person[3]; s[1]=new person(); C .person p[]= new student[3];p[1]= new person(); D .student s[]=new student[3];s[1]=new person; 9 编译MyClass.java之后,得到了三个字节码文件:MyClass.class , MyClasslittle$.class MyClass$1.class.这表明(C) A.MyClass类中的两个方法:little和1 B. MyClass.Java中有三个类:MyClass、little和1 C. MyClass类中有两个内部类:一个是命名的little,另一个是匿名的1 D. MyClass、little和1,这三者没什么关系 10、main 方法是java Application 程序执行的入口点,关于main方法的方法头以下(B)是合法的。 A.public static void main() B.public static void main(String arg[]) C.public static int main(String[] arg) D. B.public void main(String arg[]) 11、当编译和运行下面的代码会出现什么情况?(A)

java考证试题

一、单选题(共计60题) (1)下列有关事件监听器的描述正确的是()。 A、一个监听器只能接受一个组件产生的事件 B、只有一个监听器可以被附加到一个组件上 C、多个监听器可以被附加到一个组件 D、以上描述都不对 (2)当下列程序执行时,其输出结果是()。 A、2k B、7k C、-7k D、-3k (3)下列关于修饰符混用的说法错误的是()。 A、abstract不能与final并列修饰同一个类 B、staic方法中能处理非static的属性 C、abstract方法必须在abstract类中 D、abstract类中不可以有private的成员 (4)下列容器是从java.awt.W indow继承的是()。 A、Applet B、Panel C、Container D、Frame (5)关于构造方法,下列叙述错误的是()。 A、构造方法是类的一种特殊方法,它的方法名必须与类名相同 B、构造方法的返回类型只能是void型,且书写格式是在方法名前加void前缀 C、构造方法的主要作用是完成对类的对象的初始化工作 D、一般在创建新对象时,系统会自动调用构造方法 (6)下面2个文件位于相同目录下,编译运行后会出现的情况是()。 //File P1.java package MyPackage; class P1{ void afancymethod(){ Sy stem.out.println("What a fancy method"); } } //File P2.java public class P2 extends P1{ public static void main(String argv[]){ P2 p2 = new P2();

COREJAVA第一阶段笔试题_答案(2)

选用的题目如下: 01.数组有没有length()这个方法? String有没有length()这个方法? 数组没有length方法数组提供的获得元素个数的方式是通过访问数组的length属性String也就是字符串类型有length()用于返回字符串的字符个数也就是俗话说的字数但是字符数和字节数是不同的 int num = str.getBytes().length - str.length(); 可以得到一个字符串当中有多少个汉字 02.Overload和Override的区别。Overloaded的方法是否可以改变返回值的类型?为什么? Overload:方法重载指发生在同一类当中,方法名字相同,参数列表(类型、个数、顺序)不同的两个方法 (体现静态多态) Override:方法覆盖发生在有继承关系的两个类之间子类类型当中访问控制权限修饰符不能更严格抛出的异常种类不能更广泛 方法重载的时候可以改变返回值的类型return type maybe different 因为方法名字和参数列表一旦确定在一个类当中就可以唯一确认一个方法所以即便方法返回类型不同 也能判断出来调用的是哪个方法,因而不会出错 03.== 与equals 有何区别? == 是Java当中的运算符用于比较两个引用当中存放的内存地址也就是内存指向是否相同 或者说用于判断两个对象是否是同一个对象 equals()是Java当中所有类型的父类既Object类当中的一个方法用于任何一个子类类型 通过覆盖equals从而给这个类型提供另外一种比较规则(因为java当中没有运算符重载) 很多人看到equals就认为是比较内容的方法其实不然在Object类当中equals方法当中也是采用==实现比较 04abstract class和interface有什么区别? 抽象类当中可以定义普通的属性可以定义普通的方法(有完整方法体的方法), 抽象类依然是Object的子类类型 interface从某种意义上应当理解成为更为纯粹的抽象类当时其中只能定义抽象方法和常量 接口当中定义的变量默认就是常量接口当中定义的方法默认就是抽象方法 接口的概念没有父类换言之接口不是Object类型的子类类型 05.接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)? 接口可以继承接口而且可以多重继承在继承多个接口的同时子接口等价于两个接口

JAVA期末考试考卷及答案

《J A V A语言程序设计》期末考试模拟试题 一、单选择题(每小题2分,共10分) 1、编译Java Application 源程序文件将产生相应的字节码文件,这些字节码文件的扩展 名为( B )。 A. .java B. .class C. .html D. .exe 2、设 x = 1 , y = 2 , z = 3,则表达式 y+=z--/++x 的值是( A )。 A. 3 B. 3. 5 C. 4 D. 5 3、在Java Applet程序用户自定义的Applet子类中,一般需要重载父类的( D )方 法来完成一些画图操作。 A. start( ) B. stop( ) C. init( ) D. paint( ) 4、不允许作为类及类成员的访问控制符的是( C )。 A. public B. private C. static D. protected 5、为AB类的一个无形式参数无返回值的方法method书写方法头,使得使用类名AB作为 前缀就可以调用它,该方法头的形式为( A )。 A. static void method( ) B. public void method( ) C. final void method( ) D. abstract void method( ) 二、填空题(每空格1分,共20分) 1、开发与运行Java程序需要经过的三个主要步骤为编辑源程序、 编译生成字节码和解释运行字节码。

MyApplet必须是 Applet 类的子类并且存储该源程序文件的文件名为MyApplet 。 3、如果一个Java Applet程序文件中定义有3个类,则使用Sun公司的JDK编译 器编译该源程序文件将产生 3 个文件名与类名相同而扩展名为 . class 的字节码文件。 4、在Java的基本数据类型中,char型采用Unicode编码方案,每个Unicode码占 用 2 字节内存空间,这样,无论是中文字符还是英文字符,都是占 用 2 字节内存空间。 5、设 x = 2 ,则表达式 ( x + + )/3 的值是 1 。 6、若x = 5,y = 10,则x < y和x >= y的逻辑值分别为 true 和 false 。 7、抽象(abstract)方法方法是一种仅有方法头,没有具体方法体和操作实现的方法,该方法必须在抽象类之中定义。最终(final)方法方法是不能被当前类的子类重新定义的方法。 8、创建一个名为 MyPackage 的包的语句是 package MyPackag , 该语句应该放在程序的位置为:应该在程序第一句。 9、设有数组定义:int MyIntArray[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70}; 则执行以下几个语句后的输出结果是 120 。 int s = 0 ; for ( int i = 0 ; i < ; i + + ) if ( i % 2 = = 1 ) s += MyIntArray[i] ; 10、在Java程序中,通过类的定义只能实现单重继承,但通过接口的定义可以实现多重继承关系。

CoreJava第一次考试——1

考试一 试题类型:不定项选择题 试题1指出下面语句编译错误的是() A. byte b=128; B. boolean flag=null; C. long a = 2147483648L; D. float f=0.9239; 试题2完成代码计算10的阶乘并输出,应该填入的代码是()… … long result = 1; for(int i = 2; i <= 10; i++) { < 填入代码 > } System.out.println("result= " + result); … … A. result = result * i; B. result = i*i; C. result = i*(i+1); D. reslut = i*(i-1); 试题3下列关于数组的声明错误的是()

A. int[] arry = new int[100]; B. int[3] arry = {1,2,3} C. int[] arry = new int[]{1,2,3} D. int[][] arry = new int[3][] 试题4语句System.out.println(1+2+"java"+3+4)输出的结果是()。 A. 3java34 B. 12java34 C. 3java7 D. 12java7 试题5下面程序的输出结果是() public static void main(String[] args) { int d = 325; int sum = 0; while (d > 0) { int n = d % 10; sum += n; d /= 10; } System.out.println(sum);

Java期末考试试卷1

信息学院2006—2007学年第二学期期末考试试题A 课程名称:Java 语言程序设计主讲:年级: 班级姓名学号 题号一二三四五合计 分数 一、选择(每题1分,共20分) 1.有一个名为MyClass的public类,想成功编译需满足以下哪个条件?() A. MyClass类中必须定义一个正确的main()方法。 B. MyClass必须定义在MyClass.java源文件中。 C. MyClass类必须定义在MyClass包中。 D. MyClass类必须被导入。 2.以下哪些修饰符不能用于顶层类?( ) A. public B. private C. abstract D. final 3.以下哪个是java中合法的关键字?( ) A. array B. Boolean C. protect D. super 4.以下哪些是合法的标识符?( ) A.%abcd B. 2abcd C. package D. _a_long_name 5.在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数的个数、类型或顺序各不相同。这种面向对象程序的特性称为. () A、隐藏 B、覆盖 C、重载 D、Java不支持此特性 6.有以下代码,请问该程序的运行结果是什么?( ) class Example { public static void main(String args[]){ boolean b=true; System.out.println(b); } } A. 打印输出true B. 打印输出1 C.编译错误 D. 无内容输出 7.以下哪些是基本数据类型?( ) A.int B. String C. Integer D. Float 8. 给出以下代码,请选择正确的选项?( ) class Example{ public static void main(String[] args){ char a=”\u1234”; } } A. 代码编译成功 B. 代码编译成功,但有警告 C. 代码编译失败 9.以下哪个语句用于声明一个二维数组?( ) A. int[5][5] a=new int[][]; B. int a=new int[5,5] C. int[][] a=new int[5][5]; D. int[][] a=new [5]int[5]; 10.给出以下代码,请问该程序的运行结果是什么?()

java集合-练习题解析

1. 填空 Collection 接口的特点是元素是___无序可重复______; List 接口的特点是元素__有__(有|无)顺序,_可以___(可以|不可以)重复; Set 接口的特点是元素__无___(有|无)顺序,____不可以__(可以|不可以)重复;Map 接口的特点是元素是__key、value映射______,其中__value__可以重复,_key___不可以重复。 2. (List)有如下代码 import java.util.*; public class TestList{ public static void main(String args[]){ List list = new ArrayList(); list.add(“Hello”); list.add(“World”); list.add(1, “Learn”); list.add(1, “Java”); printList(list); } public static void printList(List list){ //1 for(int i = 0; i< list.size();i++){ System.out.println(list.get(i)); } for(Object o : list) { System.out.println(o); } Iterator itor = list.iterator(); while(itor.hasNext()){ System.out.println(itor.next()); } } } 要求: 1) 把//1 处的代码补充完整,要求输出list 中所有元素的内容 2) 写出程序执行的结果Hello Java Learn World 3) 如果要把实现类由ArrayList 换为LinkedList,应该改哪里?ArrayList 和LinkedList 使用上有什么区别?实现上有什么区别? 4) 如果要把实现类由ArrayList 换为Vector,应该改哪里?ArrayList 和Vector 使 用上有什么区别?实现上有什么区别? 3. (List)写出下面程序的运行结果

Java期末考试习题库

一、选择题 1、下面关于变量及其作用范围的陈述哪个是不对的?(B ) A.实例变量是类的成员变量。 B.实例变量用关键字static声明。 C.在方法中定义的局部变量在该方法被执行时创建。 D.局部变量在使用前必须被初始化。 2、下面哪条语句把方法声明为抽象的公共方法?(B ) A.public abstract method(); B.public abstract void method(); C.public abstract void method(){} D.public void method() extends abstract; 3、哪个是将一个十六进制值赋值给一个long型变量?(D ) A.long number = 345L; B.long number = 0345; C.long number = 0345L; D.long number = 0x345L; 4、下面的哪个赋值语句是不对的?(A ) A.float f = 11.1; B.double d = 5.3E12; C.double d = 3.14159; D.double d = 3.14D; 5、下面哪个是不合法的标识符?(C ) A.$persons; B.TwoUsers; C.*point; D._endline; 6、若在某一个类定义中定义有如下的方法:final void aFinalFunction( ); 则该方法属于( C )。 A、本地方法 B、静态方法 C、最终方法 D、抽象方法 7、main方法是Java Application程序执行的入口点,关于main方法的方法头以下哪项是合 法的( B )。 A、public static void main() B、public static void main(String[ ] args) C、public static int main(String[ ] args) D、public void main(String arg[ ]) 8、在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数个数、类型或顺序 各不相同,传回的值也可以不相同。这种面向对象程序的特性称为( C )。 A、隐藏 B、覆盖 C、重载 D、Java不支持此特性 9、在Java applet程序中,用户自定义的Applet子类常常覆盖父类的( C )方法来完成 applet界面的初始化工作。

JAVA期末考试题库

判断题1到72为正确,101之后为错误! 1.Java是一种严格的面向对象语言,编写的所有代码都限定在类内完成。 2.Java中引入包的概念是为了减少命名冲突,扩大名字空间。 3.Java既是开发环境,又是应用环境,它代表了一种新的计算模式。 4.Java中的数组是用来表示一组同类型数据的数据结构,且数组是定长的,初始化以后,数组的大小不会再动态变化。 5.Java中的字符串是内存中连续排列的一个或多个字符。 6.Java的封装性体现在将方法和数据封装在一个类中。 7.Java中的每种事件类都有一个对应的接口,接口中申明了一个或多个抽象的事件处理方法,凡是需要接收并处理事件类对象的类,都需要实现相应的接口。 9.在Java中,使用构造函数是生成对象的唯一方法。 10.在Java中,this用于指代本类,super用于指代其父类。 11.在Java中,n维数组只是n-1维数组的数组。 12.在Java中,复合语句是一对花括号“{”和“}”括起来的语句组,也称为块。从这种意义上说,类定义和方法定义都可以看作一个块。 13.在Java中,环境变量classpath将指示javac编译器如何查找所需要的对象。

14.如果Java文件中包含一个公有类,则该文件的文件名必须与该公有类一致。 15.语句是Java最小的执行单元,各语句间以分号分隔。 16.一个Java源文件可包括一个package语句和任意多个import语句,但package语句必须在前面。 17.Object是Java程序中所有类的直接和间接父类,也是类库中所有类的父类,处在类层次的最高点。 18.JVM的代码格式为压缩的字节码,因而效率较高。 19.OOP技术把问题看成是相互作用的事物的集合,用属性来描述事物,而把对它的操作定义为方法。 20.在访问权限修饰符中,protected修饰符和无修饰符时的根本区别仅在于不同包的子类是否可以对其访问。 21.static成员与类相对应,不需要创建对象就可使用。 22.在while循环中,循环体有可能一次也不执行。 23.Vector类中的元素不能是简单数据类型。 21.Vector是一组对象的集合,可以表达一个完整的数据序列。 22.在创建Vector序列时,不需要指明序列中元素的类型,可以在使用时确定。 23.如果要将整数15存入一个Vector向量中,需采用封装类Integer将其转化为对象。 24.语句“char a=78;”可正常通过编译,因为Java编译系统

java认证考试试题2422-3-

一、 1、下列叙述中,正确的是( Java语言的标识符是区分大小写的) 2、在软件开发中,下面任务不属于设计阶段的是(定义需求并建立系统模型) 3、Java虚拟机的执行过程有多个特点,下列哪个特点不属于JVM执行特点?(异步处理) 4、在关系数据库中,用来表示实体之间联系的是(二维表) 5、能够支持 javadoc 命令的注释语句是( D、/**...*/) 6、在匹配器(Matcher)类中,用于输入字符串与模式串比较的方法是(static boolean matches()) 7、给出下面程序段: if(x>0){System.out.println("Hello.");} else if(x>-3){System.out.println("Nice to meet you!");} else {System.out.println("How are you?");} 若打印字符串“How are you?”,则x的取值范围是(x<=-3) 8、编译并且执行以下代码,会出现什么情况?(2) public class Q{ public static void main(String argv[]){ int anar[]=new int[]{1,2,3}; System.out.println(anar[1]); } } 9、下面属于Java 关键字的是(do) 10、在Java 中,由Java编译器自动导入,而无需在程序中用import导入的包是(java、lang) 二、1. Which correctly create an array of five empty Strings? (String a[] = new String[5];for (int i=0;i<5;a[i++]=””);) 2. 哪些不是Java关键字? (1. TRUE; 2. sizeof ) 3. 下面哪些是合法的标识符。(1. $persons 2.TwoUsers) 4. 哪些类可以作为FileInputStream类的构造方法的参数?(1.File ;2.

CoreJava第三次内测试卷

《CoreJava第三次内测》 一、单选题(共33分,每题2分,共66分) 1.下列对Java中的继承描述错误的说法是()。 A.子类至少有一个基类 B.子类可作为另一个子类的基类 C.子类除了包含它直接定义的属性外,还包含其父类的私有属性 D.子类继承父类的方法访问权限保持不变 2.try {}里有一个return语句,那么紧跟在这个try后的finally {}里的代码会不会被执行,什么时候被执行? ( ) A.不会执行 B.会执行,在return前执行 C.会执行,在return后执行 D.会执行,可能在return前执行,也可能在return后执行 3.构造方法是否可被重写和重载()。 A.不能重写,可以重载 B.可以重写,不能重载 C.不能重写,不能重载 D.可以重写,可以重载 4.给出一段程序,试判断哪个是正确的结果() public class rtExcept{ public static void throwit(){ System.out.print(“throwit”); throw new RuntimeException(); } public static void main(String [] aa){ try{ System.out.print(“hello “); throwit(); } catch(Exception re){ System.out.print(“caught ”); } finally{ System.out.print(“finally ”); } System.out.print(“after ”); } } A、hello throwit caught B、hello throwit caught finally after C、hello throwit RuntimeException after D、hello throwit caught finally after RuntimeException 5.给出一段程序,试判断哪个是正确的结果() public class myprogram{ public static void main (String args[]){ try{ System.out.print(“Hello world ”); } finally{ System.out.println(“Finally executing”); }}} A、无法编译,因为没有指定异常 B、无法编译,因为没有catch子句 C、Hello world D、Hello world Finally executing 6.对于catch子句的排列,下列哪种是正确的( ) A.父类在先,子类在后 B.子类在先,父类在后 C.有继承关系的异常不能在同一个try程序段内 D.一个try后只能放一个catch 7.Java中,泛型数据类型声明可能出现的符号是( ) A.R B.D C.T D.都可以 8.关于Java中异常的叙述正确的是:() A.异常是程序编写过程中代码的语法错误B.异常是程序编写过程中代码的逻辑错误C.异常出现后程序的运行马上中止D.异常是可以捕获和处理的 9.所有的异常和错误皆继承哪一个类?() A.java.io.Exception B.https://www.wendangku.net/doc/3317999280.html,ng. Exception C.https://www.wendangku.net/doc/3317999280.html,ng. Throwable D.https://www.wendangku.net/doc/3317999280.html,ng.Error 10.下列关于try-catch-finally语句的描述中,错误的是() A.try语句后面的程序段将给出处理异常的语句 B.catch()方法跟在try语句后面,它可以是一个或多个 C.catch()方法有一个参数,该参数是某种异常类的对象 D.finally语句后面的程序段总是被执行的,该语句起到提供统一接口的作用 11.给出下面的代码

相关文档