SCJP模拟题 AND Answer[2](4)

2019-08-30 12:58

13. Tester() {

14. System.out.println(\15. }

16. public static void main(String args[]) { 17. Tester t = new Tester(5); 18. }

a. \b. 5

c. \d. \

Q32

What are the range of values for a variable of type short? a. -2^7 to 2^7-1 b. 0 to 2^8 c. -2^15 to 2^15-1 d. -2^15-1 to 2^15

Q33

Analyze the following two classes

1. class First { 2. static int a = 3; 3. }

4. final class Second extends First { 5. void method() { 6. System.out.println(a); 7. } 8. }

a. Class First compiles, but class Second does not. b. Neither class compiles.

c. Both classes compile, and if method() is invoked, it writes 3 to the output. d. Both classes compile, and if method() is invoked, it throws an exception. Q34

What String instance method would return true when invoked as follows?

1. a.method(b);

where a equals \a. equals() b. toLowerCase() c. toUpperCase() d. equalsIgnoreCase()

Q35

What access control keyword should you use to enable other classes to access a method freely within its package, but to restrict classes outside of the package from accessing that method? Select all valid answers.

a. private b. public c. protected

d. Do not supply an access control keyword (friendly). Q36

What letters are written to the standard output with the following code?

1. class Unchecked {

2. public static void main(String args[]) { 3. try { 4. method();

5. } catch(Exception e) { } 6. }

7. static void method() { 8. try { 9. wrench();

10. System.out.println(\

11. } catch(ArithmeticException e) { 12. System.out.println(\13. } finally {

14. System.out.println(\15. }

16. System.out.println(\17. }

18. static void wrench() {

19. throw new NullPointerException(); 20. } 21. }

Select all valid answers. a. \b. \c. \d. \Q37

If you would like to change the size of a Component, you can use the following method a. size() b. resize() c. setSize() d. dimension() Q38

Which LayoutManager arranges components left to right and then top to bottom, centering each row as it moves to the next row? a. BorderLayout b. FlowLayout c. GridLayout d. CardLayout Q39

Which label names(s) are illegal? Select all valid answers. a. here b. _there c. this d. 2to1odds Q40

Which keyword, when used in front of a method, must also appear in front of the class. a. synchronized b. abstract c. public d. private

Q41

Given this code snippet, 1. try { 2. tryThis(); 3. return;

4. } catch(IOException x1) {

5. System.out.println(\6. return;

7. } catch(Exception x2) {

8. System.out.println(\9. return; 10. } finally {

11. System.out.println(\12. }

what will appear in the standard output if tryThis() throws a IOException? a. \b. \c. \d. \ Q42

Given the code snippet, 1. double a = 90.7; 2. double b = method(a); 3. System.out.println(b);

if this snippet displays 90.0 in the standard output, what Math method did method() invoke? Select all valid answers. a. abs() b. round() c. floor() d. ceil()

Q43

What is written to the standard output given the following statement

1. System.out.println(4 | 7); a. 4 b. 5 c. 6 d. 7 Q44

What expressions are true concerning the following lines of code?

1. int[] arr = {1, 2, 3}; 2. for(int i = 0 ; i < 2; i++) 3. arr[i] = 0;

Select all valid answers. a. arr[0] == 0 b. arr[1] == 2 c. arr[1] == 0 d. arr[2] == 3 Q45

What will the following block of code write to standard output when it is executed?

1. int i = 3; 2. int j = 0; 3. double k = 3.2; 4. if (i < k) 5. if (i == j)

6. System.out.println(i); 7. else

8. System.out.println(j); 9. else

10. System.out.println(k); a. 3 b. 0 c. 3.2

d. None of these.

Q46

What is the output of the following piece of code


SCJP模拟题 AND Answer[2](4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:自考混凝土及砌体结构模拟试题A卷(附答案)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: