JAVA认证真题:SCJP考试题310-025第二套(4)
来源:优易学  2009-11-28 11:03:56   【优易学:中国教育考试门户网】   资料下载   IT书店
文章页内部300*250广告位

 

QUESTION NO 116
Given:
1. public class Test {
2. public static void main (String []args) {
3. unsigned byte b = 0;
4. b--;
5.
6. }
7. }
What is the value of b at line 5?
A. -1
B. 255
C. 127
D. Compilation will fail.
E. Compilation will succeed but the program will throw an exception at line 4.
Answer: D
QUESTION NO 117
Given:
1. public class Foo {
2. public void main (String [] args) {
3. system.out.printIn(“Hello World.”);
4. }
5. }
What is the result?
A. An exception is thrown.
B. The code does no compile.
C. “Hello World.” Is printed to the terminal.
D. The program exits without printing anything.
Answer: A
QUESTION NO 118
Given:
1. //point X
2. public class foo (
3. public static void main (String[]args) throws Exception {
4. java.io.printWriter out = new java.io.PrintWriter (
5. new 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.*;
B. Include java.io.*;
C. Import java.io.PrintWriter;
D. Include java.io.PrintWriter;
E. No statement is needed.
Answer: E
QUESTION NO 119
Which will declare a method that is available to all members of the same package and can be referenced
without an instance of the class?
A. Abstract public void methoda();
B. Public abstract double methoda();
C. Static void methoda(double d1){}
D. Public native double methoda() {}
E. Protected void methoda(double d1) {}
Answer: C
QUESTION NO 120
Which type of event indicates a key pressed on a java.awt.Component?
A. KeyEvent
B. KeyDownEvent
C. KeyPressEvent
D. KeyTypedEvent
E. KeyPressedEvent
Answer: A
QUESTION NO 121
Exhibit:
1. import java.awt.*;
2.
3. public class X extends Frame {
4. public static void main (String [] args) {
5. X x = new X();
6. x.pack();
7. x.setVisible(true);
8. }
9.
10. public X() {
11. setLayout (new BordrLayout());
12. Panel p = new Panel ();
13. add(p, BorderLayout.NORTH);
14. Button b = new Button (“North”);
15. p.add(b):
16. Button b = new Button (“South”);
17. add(b1, BorderLayout.SOUTH):
18. }
19. }
Which two statements are true? (Choose Two)
A. The buttons labeled “North” and “South” will have the same width.
B. The buttons labeled “North” and “South” will have the same height.
C. The height of the button labeled “North” can very if the Frame is resized.
D. The height of the button labeled “South” can very if the Frame is resized.
E. The width of the button labeled “North” is constant even if the Frame is resized.
F. The width of the button labeled “South” is constant even if the Frame is resized.
Answer: B, E
QUESTION NO 122
How can you create a listener class that receives events when the mouse is moved?
A. By extending MouseListener.
B. By implementing MouseListener.
C. By extending MouseMotionListener.
D. By implementing MouseMotionListener.
E. Either by extending MouseMotionListener or extending MouseListener.
F. Either by implementing MouseMotion Listener or implementing MouseListener.
Answer: D

QUESTION NO 123
Which statement is true?
A. A grid bag layout can position components such that they span multiple rows and/or columns.
B. The “North” region of a border layout is the proper place to locate a menuBar component in a
Frame.
C. Components in a grid bag layout may either resize with their cell, or remain centered in that cell at
their preferred size.
D. A border layout can be used to position a component that should maintain a constant size even
when the container is resized.
Answer: A
QUESTION NO 124
You want a class to have access to members of another class in the same package. Which is the most
restrictive access modifier that will accomplish that will accomplish this objective?
A. Public
B. Private
C. Protected
D. Transient
E. No access modifier is required.
Answer: E
QUESTION NO 125
Which two statements are true regarding the creation of a default constructor? (Choose Two)
A. The default constructor initializes method variables.
B. The default constructor invokes the no-parameter constructor of the superclass.
C. The default constructor initializes the instance variables declared in the class.
D. If a class lacks a no-parameter constructor,, but has other constructors, the compiler creates a
default constructor.
E. The compiler creates a default constructor only when there are no other constructors for the class.
Answer: C, E
QUESTION NO 126
Given:
1. public class OuterClass {
2. private double d1 1.0;
3. //insert code here
4. }
You need to insert an inner class declaration at line2. Which two inner class declarations are valid?
(Choose Two)
A. static class InnerOne {
public double methoda() {return d1;}
}
B. static class InnerOne {
static double methoda() {return d1;}
}
C. private class InnerOne {
public double methoda() {return d1;}
}
D. protected class InnerOne {
static double methoda() {return d1;}
}
E. public abstract class InnerOne {
public abstract double methoda();
}
Answer: C, E

QUESTION NO 127
Which two declarations prevent the overriding of a method? (Choose Two)
A. Final void methoda() {}
B. Void final methoda() {}
C. Static void methoda() {}
D. Static final void methoda() {}
E. Final abstract void methoda() {}
Answer: A, D
QUESTION NO 128
Given:
1. public class Test {
2. public static void main (String args[]) {
3. class Foo {
4. public int i = 3;
5. }
6. Object o = (Object) new Foo();
7. Foo foo = (Foo)o;
8. System.out.printIn(foo. i);
9. }
10. }
What is the result?
A. Compilation will fail.
B. Compilation will succeed and the program will print “3”
C. Compilation will succeed but the program will throw a ClassCastException at line 6.
D. Compilation will succeed but the program will throw a ClassCastException at line 7.
Answer: B
QUESTION NO 129
Which two create an instance of an array? (Choose Two)
A. int[] ia = new int [15];
B. float fa = new float [20];
C. char[] ca = “Some String”;
D. Object oa = new float[20];
E. Int ia [][] = (4, 5, 6) (1, 2, 3)
Answer: A, D
QUESTION NO 130
Given:
1. public class ExceptionTest {
2. class TestException extends Exception {}
3. public void runTest () throws TestException {}
4. public void test () /* Point X*/ {
5. runTest ();
6. }
7. }
At point X on line 4, which code can be added to make the code compile?
A. Throws Exception.
B. Catch (Exception e).
C. Throws RuntimeException.
D. Catch (TestException e).
E. No code is necessary.
Answer: B

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

责任编辑:小草

收藏此页】【 】【打印】【回到顶部
计算机文章页底部500*200广告
文章搜索:
 相关文章
计算机底部580*90广告
文章页右侧第一330*280广告
计算机文章页资讯推荐
热点资讯
文章页330尺寸谷歌广告位
热门课程培训