`

SCJP practice

    博客分类:
  • SCJP
阅读更多

Q1:

     1. public class MethodOver {
     2. public void setVar (int a, int b, float c) {
     3. }
     4. }

     Which two overload the setVar method? (Choose Two)

     A. Private void setVar (int a, float c, int b) { }
     B. Protected void setVar (int a, int b, float c) { }
     C. Public int setVar (int a, float c, int b) (return a;)
     D. Public int setVar (int a, int b, float c) (return a;)
     E. Protected float setVar (int a, int b, float c) (return c;)

Answer:   A,C

 

Q2:

    1. public class ConstOver {
     2. public ConstOver (int x, int y, int z) {
     3. }
     4. }

     Which two overload the ConstOver constructor? (Choose Two)

     A. ConstOver ( ) { }
     B. Protected int ConstOver ( ) { }
     C. Private ConstOver (int z, int y, byte x) { }
     D. Public Object ConstOver (int x, int y, int z) { }
     E. Public void ConstOver (byte x, byte y, byte z) { }

Answer: AC

 

Q3:

    1. public class test {
     2. public static void add3 (Integer i) }
     3. int val = i.intValue ( );
     4. val += 3;
     5. i = new Integer (val);
     6. }
     7.
     8. public static void main (String args [ ] ) {
     9. Integer i = new Integer (0);
     10. add3 (i);
     11. system.out.printIn (i.intValue ( ) );
     12. }
     13. )

     What is the result?

     A. Compilation will fail.
     B. The program prints “0”.
     C. The program prints “3”.
     D. Compilation will succeed but an exception will be thrown at line 3.

Answer: B

 

Q4:

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics