SCJP考试题-3

日志 > 软件编程
设置置顶 | 编辑 | 删除

SCJP考试题-3

发表于:2008年4月30日 13时54分55秒阅读(4)评论(0) 本文链接:http://user.qzone.qq.com/169188811/blog/1209534895
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
QUESTION NO 131
Exhibit:
1. public class SwitchTest {
2. public static void main (String []args) {
3. System.out.PrintIn(“value =” +switchIt(4));
4. }
5. public static int switchIt(int x) {
6. int j = 1;
7. switch (x) {
8. case 1: j++;
9. case 2: j++;
10. case 3: j++;
11. case 4: j++;
12. case 5: j++;
13. default:j++;
14. }
15. return j + x;
16. }
17. }
What is the output from line 3?
A. Value = 3
B. Value = 4
C. Value = 5
D. Value = 6
E. Value = 7
F. Value = 8
Answer: F
QUESTION NO 132
Which four types of objects can be thrown using the throw statement? (Choose Four)
A. Error
B. Event
C. Object
D. Exception
E. Throwable
F. RuntimeException
Answer: A, D, E, F
QUESTION NO 133
Given:
1. public class ForBar {
2. public static void main(String []args) {
3. int i = 0, j = 5;
4. tp: for (;;) {
5. i ++;
6. for(;;)
7. if(i > --j) break tp;
8. }
9. system.out.printIn(“i = ” + i + “, j = “+ j);
10. }
11. }
What is the result?
A. The program runs and prints “i=1, j=0”
B. The program runs and prints “i=1, j=4”
C. The program runs and prints “i=3, j=4”
D. The program runs and prints “i=3, j=0”
E. An error at line 4 causes compilation to fail.
F. An error at line 7 causes compilation to fail.
Answer: A
QUESTION NO 134
Which two can directly cause a thread to stop executing? (Choose Two)
A. Exiting from a synchronized block.
B. Calling the wait method on an object.
C. Calling the notify method on an object.
D. Calling the notifyAll method on an object.
E. Calling the setPriority method on a thread object.
Answer: B, E
 
请选择道具
温馨提示:点击验证码输入框,以获取验证码
请输入验证码:
      
<script type="text/javascript"> //$1  于 $2 发表的评论
/x02").replace(//[//quote/]/g,"/x01"); for(var i=0;i<2;i++) s=s.replace(//x03([^/x03/x01/x02]*?)/x02([^/x03/x01/x02]*?)/x01/g, function(a,b,c){ return '
'+b+'引用内容:

'+c+'
'; }); return s.replace(/[/x03/x02/x01]/g,""); } var bLoaded = false; function checkMsgReply(obj) { if(!bLoaded) top.includeJS('/qzone/blog/script/common.js', function(){bLoaded=true;checkMsgReply(obj)}, document); else checkReply(obj); if(obj.checked){ MAX_COMMENT_LEN = 500; } else { MAX_COMMENT_LEN = 4500; } _fontCount = MAX_COMMENT_LEN; //字数限制 if(!window.sendCommentEditor) return; if(sendCommentEditor.editorArea.editMode == 1) toCountFont(sendCommentEditor.id, "html"); else toCountFont(sendCommentEditor.id, "text"); } function showMsgLeftCnt() { if(!bLoaded) top.includeJS('/qzone/blog/script/common.js', function(){bLoaded=true;showMsgLeftCnt();}, document); else showLeftSMS(); } function selectBlogPaper() { if(checkLogin() <= 10000) { top.showLoginBox("mall"); return; } if(!!top.g_JData["blogContent"]) { if(parent.g_iLoginUin == parent.g_iUin) { location.href="/qzone/newblog/blogeditor.html?paperid=" + parent.g_JData["blogContent"].data.lp_id + "&paperstyle=" + parent.g_JData["blogContent"].data.lp_style + "&paperdialog=1"; } else { parent.location.href="http://user.qzone.qq.com/" + parent.g_iLoginUin + "/addNewBlog?paperid=" + parent.g_JData["blogContent"].data.lp_id + "&paperstyle=" + parent.g_JData["blogContent"].data.lp_style; } } else { top.showMsgBox("抱歉,暂时无法获取该信纸信息!", 1, 2000); } } /** * 批量删除中选择全选 */ function selectAllComments(bChecked) { var oList = document.getElementsByName("commentCheckBox"); if(oList.length==0) return; for(var i=0; i 0){ dalert(null, parent.g_XDoc["delBatchReply"].xml, 2000); delete parent.g_XDoc["delBatchReply"]; return; } dalert(null, parent.g_XDoc["delBatchReply"].xml, 2000, 2); contentProperty.totalCommentNumber -= nDeleteCnt; //清理cache with(contentProperty){ delete parent.g_XDoc["blogRoot"].contentHSList[currentBlogid]; pageList = {}; pageIndexMap = []; currentCommentPage = lastCommentPage = (!contentProperty.nowaPage)?0:nowaPage[3]; parent.g_XDoc["blogRoot"].replyNumUpdateHSmap[currentBlogid] = totalCommentNumber; parent.isRefreshTop = true; if(currentCommentPage == 0) { setTimeout(contentInit, 1000); } else{ var tp = Math.ceil(totalCommentNumber/PAGE_COMMENT_NUM); var num = totalCommentNumber%PAGE_COMMENT_NUM; if(num==0 || currentCommentPage10000 && top.g_iLoginUin!=top.g_iUin) { $("msgboardSelfReply").style.display = ""; $("blogSelPaper").title = "我也要使用此信纸写日志"; } setTimeout(contentInit,50); //]]> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值