JAVA认证真题:SCJP考试题310-025第二套(1)
来源:优易学  2011-11-28 10:54:51   【优易学:中国教育考试门户网】   资料下载   IT书店


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

Question No 13
Given:
1. package foo;
2.
3. public class Outer (
4. public static class Inner (
5. )
6. )
Which statement is true?
A. An instance of the Inner class can be constructed with “new Outer.Inner ()”
B. An instance of the inner class cannot be constructed outside of package foo.
C. An instance of the inner class can only be constructed from within the outer class.
D. From within the package bar, an instance of the inner class can be constructed with “new inner()”
Answer: A
Question No 14
Exhibit:
1. public class enclosingone (
2. public class insideone{}
3. )
4. public class inertest(
5. public static void main (string[]args)(
6. enclosingone eo= new enclosingone ();
7. //insert code here
8. )
9. )
Which statement at line 7 constructs an instance of the inner class?
A. InsideOnew ei= eo.new InsideOn();
B. Eo.InsideOne ei = eo.new InsideOne();
C. InsideOne ei = EnclosingOne.new InsideOne();
D. EnclosingOne.InsideOne ei = eo.new InsideOne();
Answer: D
Question No 15
Exhibit:
1. interface foo {
2. int k = 0;
3. ]
4.
5. public class test implements Foo (
6. public static void main(String args[]) (
7. int i;
8. Test test = new test ();
9. i= test.k;
10.i= Test.k;
11.i= Foo.k;
12.)
13.)
14.
What is the result?
A. Compilation succeeds.
B. An error at line 2 causes compilation to fail.
C. An error at line 9 causes compilation to fail.
D. An error at line 10 causes compilation to fail.
E. An error at line 11 causes compilation to fail.
Answer: A
Question No 16
Given:
1. //point X
2. public class foo (
3. public static void main (String[]args) throws Exception {
4. printWriter out = new PrintWriter (new
5. java.io.outputStreamWriter (System.out), true;
6. out.printIn(“Hello”);
7. }
8. )
Which statement at PointX on line 1 allows this code to compile and run?
A. Import java.io.PrintWriter;
B. Include java.io.PrintWriter;
C. Import java.io.OutputStreamWriter;
D. Include java.io.OutputStreamWriter;
E. No statement is needed.
Answer: A
Question No 17
Which two statements are reserved words in Java? (Choose Two)
A. Run
B. Import
C. Default
D. Implement
Answer: B, C
Question No 18
Which three are valid declarations of a float? (Choose Three)
A. Float foo = -1;
B. Float foo = 1.0;
C. Float foo = 42e1;
D. Float foo = 2.02f;
E. Float foo = 3.03d;
F. Float foo = 0x0123;
Answer: A, D, F

上一页  [1] [2] 

责任编辑:小草

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