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

2019-08-30 12:58

1. public class Q11 {

2. static String str1 = \3. static String str2 = \5. public static void main(String[] args) { 6. System.out.println(str1); 7. }

10. public static void main(int[] args) { 11. System.out.println(str2); 12. } 13. }

a. Duplicate method main(), compilation error at line 5. b. Duplicate method main(), compilation error at line 10. c. Prints \d. Prints \Q10

In the following applet, how many buttons will be displayed?

1. import java.applet.*; 2. import java.awt.*;

3. public class Q16 extends Applet { 4. Button okButton = new Button(\

5. public void init() { 6. add(okButton); 7. add(okButton); 8. add(okButton); 9. add(okButton);

10. add(new Button(\14. add(new Button(\15. add(new Button(\16. add(new Button(\

18. setSize(300,300); 19. } 20. }

a. 1 Button with label \b. 1 Button with label \c. 4 Buttons with label \d. 4 Buttons with label \Q11

What is the output of the following program?

1. class Test { 2. void show() {

3. System.out.println(\4. } 5. }

6. public class Q3 extends Test { 7. static void show() {

8. System.out.println(\9. }

10. public static void main(String[] args) { 11. Q3 a = new Q3(); 12. } 13 }

a. Compilation error at line 2. b. Compilation error at line 7.

c. No compilation error, but runtime exception at line 2. d. No compilation error, but runtime exception at line 7. Q12

What will happen if you compile/run the following code?

1. public class Q21 { 2. int maxElements; 3. void Q21() { 4. maxElements = 100;

5. System.out.println(maxElements); 6. }

7. Q21(int i) { 8. maxElements = i;

9. System.out.println(maxElements); 10. }

11. public static void main(String[] args) { 12. Q21 a = new Q21(); 13. Q21 b = new Q21(999); 14. 15. } 16. }

a. Prints 100 and 999. b. Prints 999 and 100.

c. Compilation error at line 2, variable maxElements was not initialized. d. Compilation error at line 12.

Q13

Given the following class definition, which of the following methods could be legally placed after the comment //Here

1. public class Rid {

2. public void amethod(int i, String s){} 3. //Here 4. }

a. public void amethod(String s, int i) {} b. public int amethod(int i, String s) {} c. public void amethod(int i, String mystring) {} d. public void Amethod(int i, String s) {} Q14

Given the following class definition, which of the following statements would be legal after the comment //Here

1. class InOut {

2. String s= new String(\3. public void amethod(final int iArgs) { 4. int iam; 5. class Bicycle{

6. public void sayHello(){ 7. //Here

8. } //End of bicycle class 9. }

10. } //End of amethod 11. public void another(){ 12. int iOther; 13. } 14. }

a. System.out.println(s); b. System.out.println(iOther); c. System.out.println(iam); d. System.out.println(iArgs);

Q15

Which of the following methods are members of the Vector class and allow you to input a new element

a. addElement() b. insert() c. append() d. addItem() Q16

What will happen when we try to compile the following code.

1. public void WhichArray( Object x ) { 2. if( x instanceof int[] ) { 3. int[] n = (int[]) x ;

4. for( int i = 0 ; i < n.length ; i++ ){ 5. System.out.println(\6. } 7. }

8. if( x instanceof String[] ) {

9. System.out.println(\10. } 11. }

a. The compiler objects to line 2 comparing an Object with an array.

b. The compiler objects to line 3 casting an Object to an array of int primitives. c. The compiler objects to line 7 comparing an Object to an array of Objects. d. It compiles without error. Q17

Consider the following class

1. class Tester {

2. void test (int i) { System.out.println (\3. void test (String s) { System.out.println (\4.

5. public static void main (String args[]) { 6. Tester c = new Tester (); 7. char ch = 'p'; 8. c.test (ch); 9. } 10. }

Which of the following statements below is true?(Choose one.)

a. Line 3 will not compile, because void methods cannot be overridden.

b. Line 8 will not compile, because there is no conversion of test() that takes a char argument.

c. The code will compile and produce the follwing output \d. The code will compile and produce the follwing output \ Q18

You are creating a ToolBase class which will be extended by other programmers. The ToolBase class contains a single abstract method, createTool. Which of the following statements are true?

a. The ToolBase class must be declared abstract.

b. Classes extending ToolBase must not be declared abstract. c. The ToolBase class must not be declared final.

d. The following variable declaration is illegal in any context \Q19

Given the following hierarchical relationship of several classes.


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

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

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

马上注册会员

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