)18-147的文章 name=description>


SCJP考试题310-025(第二套<1>)18-147
来源:优易学  2011-9-22 19:50:24   【优易学:中国教育考试门户网】   资料下载   IT书店

 

Question No: 6
Exhibit:
1. Public class test (
2. Public static void stringReplace (String text) (
3. Text = text.replace (‘j' , ‘i');
4. )
5.
6. public static void bufferReplace (StringBuffer text) (
7. text = text.append (“C”)
8. )
9.
10. public static void main (String args[]} (
11. String textString = new String (“java”);
12. StringBuffer text BufferString = new StringBuffer (“java”);
13.
14. stringReplace (textString);
15. BufferReplace (textBuffer);
16.
17. System.out.printIn (textString + textBuffer);
18. }
19. )
What is the output?
Answer: javajavaC
Question No: 7
Exhibit:
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
Question No: 8
Given:
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: A, C
Question No: 9
Given:
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
Question No: 10
Given:
1. class BaseClass {
2. Private float x = 1.0f ;
3. protected float getVar ( ) ( return x;)
4. }
5. class Subclass extends BaseClass (
6. private float x = 2.0f;
7. //insert code here
8. )
Which two are valid examples of method overriding? (Choose Two)
A. Float getVar ( ) { return x;}
B. Public float getVar ( ) { return x;}
C. Float double getVar ( ) { return x;}
D. Public float getVar ( ) { return x;}
E. Public float getVar (float f ) { return f;}
Answer: B, D
Question No: 11
Which two demonstrate an “is a” relationship? (Choose Two)
A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Shape { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal (private Species species;)
E. interface Component { }
Class Container implements Component (
Private Component[ ] children;
)
Answer: D, E
Question No: 12
Which statement is true?
A. An anonymous inner class may be declared as final.
B. An anonymous inner class can be declared as private.
C. An anonymous inner class can implement multiple interfaces.
D. An anonymous inner class can access final variables in any enclosing scope.
E. Construction of an instance of a static inner class requires an instance of the enclosing outer class.
Answer: D

上一页  [1] [2] [3] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训