📄 解析5.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<Meta http-equiv="Pragma" Content="No-cach">
<title>SCJP认证套题解析之五 -- 最大的IT资源网</title>
<link href="/img/P5-06-css.css" rel="stylesheet" type="text/css">
</head>
<script language="JavaScript">
function GetContentWnd(){ return parent; }
function OnSave(){
var oWnd = GetContentWnd();
window.external.addFavorite(
oWnd.location.href, oWnd.document.title );
}
//双击鼠标滚动屏幕的代码
var currentpos,timer;
function initialize()
{
timer=setInterval ("scrollwindow()",80);
}
function sc()
{
clearInterval(timer);
}
function scrollwindow()
{
currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if (currentpos !=document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
<Script LANGUAGE="JavaScript">
if(self!=top){top.location=self.location;}
</script>
<body oncontextmenu="return false;" onload="setimg();">
<table width="750" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td height="26" valign="top"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td height="22" align="center"><script src="/js/P5-head.js"></script></td>
</tr>
</table></td>
</tr>
<tr>
<td height="82" align="center" valign="top"
bgcolor="#D2D2D2"><table width="750" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="80" align="center" bgcolor="#FFFFFF"><script src="/ad/k15-5-1.js"></script></td>
</tr>
</table></td>
</tr>
<tr>
<td height="30" valign="top"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td width="85" height="30"><img src="/img/P5-06-01.gif"
width="85" height="30"></td>
<td width="85"><a href="javascript:OnSave();"><img
src="/img/P5-06-02.gif" width="85" height="30" border="0"></a></td>
<td width="8" align="center" valign="top"><img src="/img/P5-06
-03.gif" width="8" height="8"></td>
<td width="8" align="left" valign="bottom"
bgcolor="#F2F2F2"><img src="/img/P5-06-04.gif" width="8"
height="8"></td>
<td width="10" bgcolor="#F2F2F2"> </td>
<td width="418" bgcolor="#F2F2F2"><a href="/">豆豆首页</a> - <a href="http://www.ddvip.net/index.htm">在线教程</a> - <a href="/cert/index.htm">认证考试</a> - <a href="/cert/java/index.htm">JAVA认证</a> - <a href="/cert/java/index3/index.htm">培训资源</a></td>
<td width="136" bgcolor="#F2F2F2"><marquee scrollamount="4">最
大的中文IT资源网
</marquee></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" align="left" cellpadding="0"
cellspacing="0">
<tr>
<td valign="top"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td align="center"> </td>
<td width="20" rowspan="2"> </td>
</tr>
<tr>
<td height="50" align="center" style="border-bottom:1px
dashed #666666"><strong class="f16">SCJP认证套题解析之五</strong></td>
</tr>
<tr>
<td height="40" align="center"> 作者:unknown 更新时间:
2005-03-22 </td>
<td rowspan="6" valign="top" style="border-right:1px solid
#666666"> </td>
</tr>
<tr>
<td height="40"> </td>
</tr>
<tr>
<td><table width="100%" border="0" cellpadding="0"
cellspacing="0" class="pagefont">
<tr>
<td><p class="line-height"><br>
21、Which of the following assignment is not correct? <br>
A. float f = 11.1; <br>
<br>
B. double d = 5.3E12; <br>
<br>
C. double d = 3.14159; <br>
<br>
D. double d = 3.14D. <br>
<br>
(a) <br>
<br>
题目:下面的哪些赋值语句是对的。 <br>
<br>
浮点数的赋值是带有小数点的数字缺省是double型的,如果在浮点数后面加f或者F则是float,后面加d或者D则是double,科学计数法形式的浮点数也是double型的,而double的精度比float高,将一个高精度的double赋值给一个低精度的float时需要进行强制类型转换,反之则不需要。 <br>
<br>
<br>
22、Given the uncompleted code of a class: <br>
class Person { <br>
String name, department; <br>
int age; <br>
public Person(String n){ name = n; } <br>
public Person(String n, int a){ name = n; age = a; } <br>
public Person(String n, String d, int a) { <br>
// doing the same as two arguments version of constructor <br>
// including assignment name=n,age=a <br>
department = d; <br>
} <br>
} <br>
Which expression can be added at the "doing the same as..." part of the constructor? <br>
<br>
A. Person(n,a); <br>
<br>
B. this(Person(n,a)); <br>
<br>
C. this(n,a); <br>
<br>
D. this(name,age). <br>
<br>
(c) <br>
<br>
题目:给出下面的不完整的类代码: <br>
… <br>
下面的哪些表达式可以加到构造方法中的"doing the same as..."处? <br>
<br>
在同一个类的不同构造方法中调用该类的其它构造方法需要使用this(…)的形式,而且必须是在构造方法的第一行调用,这个和普通的方法重载调用的方式不同,普通的方法可以直接使用方法名加参数来调用,而且调用位置没有限制,因此答案A是不行的,B的语法就是错误的,D的错误在于在父类型的构造函数被调用前不能引用类的成员。构造方法是一个类对象实例化的起点(虽然严格来说首先执行的并不是构造方法的第一个语句,而是内存的分配),因此在构造方法中不能将成员作为参数引用。 <br>
<br>
23、Which of the following statements about variables and their scopes are true? <br>
<br>
A. Instance variables are member variables of a class. <br>
<br>
B. Instance variables are declared with the static keyword. <br>
<br>
C. Local variables defined inside a method are created when the method is executed. <br>
<br>
D. Local variables must be initialized before they are used. <br>
(acd) <br>
<br>
题目:下面关于变量及其范围的陈述哪些是对的。 <br>
<br>
A. 实例变量是类的成员变量。 <br>
<br>
B. 实例变量用关键字static声明。 <br>
<br>
C. 在方法中定义的局部变量在该方法被执行时创建 <br>
<br>
D. 局部变量在使用前必须被初始化。 <br>
<br>
类中有几种变量,分别是:局部变量(英文可以为:local\automatic\temporary\stack variable)是定义在方法里的变量;实例变量(英文为:instance variable)是在方法外而在类声明内定义的变量,有时也叫成员变量;类变量(英文为:class variable)是用关键字static声明的实例变量,他们的生存期分别是:局部变量在定义该变量的方法被调用时被创建,而在该方法退出后被撤销;实例变量在使用new Xxxx()创建该类的实例时被创建,而其生存期和该类的实例对象的生存期相同;类变量在该类被加载时被创建,不一定要用new Xxxx()创建,所有该类的实例对象共享该类变量,其生存期是类的生存期。任何变量在使用前都必须初始化,但是需要指出的是局部变量必须显式初始化,而实例变量不必,原始类型的实例变量在该类的构造方法被调用时为它分配的缺省的值,整型是0,布尔型是false,而浮点型是0.0f,引用类型(类类型)的实例变量的缺省值是null(没有进行实际的初始化,对它的使用将引起NullPointException),类变量的规则和实例变量一样,不同的是类变量的初始化是在类被加载时。 <br>
<br>
24、public void test() { <br>
try { oneMethod(); <br>
System.out.println("condition 1"); <br>
} catch (ArrayIndexOutOfBoundsException e) { <br>
System.out.println("condition 2"); <br>
} catch(Exception e) { <br>
System.out.println("condition 3"); <br>
} finally { <br>
System.out.println("finally"); <br>
} <br>
<br>
} <br>
Which will display if oneMethod run normally? <br>
A. condition 1 <br>
<br>
B. condition 2 <br>
<br>
C. condition 3 <br>
<br>
D. finally <br>
<br>
(ad) <br>
<br>
题目:在oneMethod()方法运行正常的情况下将显示什么? <br>
<br>
如果try块中的语句在执行时发生异常,则执行从该处中断而进入catch块,根据异常的类型进行匹配,最前面的优先进行匹配比较,只要该异常是catch中指定的异常的子类就匹配成功进而执行相应的catch中的内容,而finally块中的内容无论是否发生异常都将被执行。 <br>
<br>
25、Given the following code: <br>
public class Test { <br>
void printValue(int m){ <br>
do { System.out.println("The value is"+m); <br>
} <br>
while( --m > 10 ) <br>
} <br>
public static void main(String arg[]) { <br>
int i=10; <br>
Test t= new Test(); <br>
t.printValue(i); <br>
} <br>
} <br>
Which will be output? <br>
A. The value is 8 <br>
B. The value is 9 <br>
<br>
C. The value is 10 <br>
<br>
D. The value is 11 <br>
<br>
(c) <br>
<br>
题目:给出下面的代码: <br>
… <br>
输出将是什么? <br>
<br>
此题考察的是do… while循环和 -- 操作符的知识,do…while最少被执行一次,在执行完do中的内容后判断while中的条件是否为true,如果为true的话就再执行do中的内容,然后再进行判断,以此类推直到while的判断为false时退出循环执行循环后面的内容,而—操作符的规则是在变量右边的-- 将先进行运算,然后才是使变量的值减一,而在变量左边的是先将变量的值减一再运算。 <br>
</p></td>
</tr>
</table></td>
</tr>
<tr>
<td height="40" align="center"> </td>
</tr>
<tr>
<td height="60" align="center" class="pagefont"><a href="4.htm">上一篇</a> <a href="index.htm">目录</a> <a href="6.htm">下一篇</a> </td>
</tr>
<tr>
<td height="30" align="right">来源:unknown</td>
</tr>
<tr>
<td height="30" align="right"><script src="/js/work.js"></script></td>
</tr>
<tr>
<td height="80" align="center" valign="middle"><script src="/ad/k15-5-2.js"></script></td>
<td rowspan="11" valign="middle"> </td>
</tr>
<tr>
<td height="220" valign="middle"><table width="100%"
border="0" cellpadding="0" cellspacing="0" style="border:1px solid
#D2D2D2">
<tr>
<td width="30" height="24" align="center"
class="point01" style="border-bottom:1px solid #D2D2D2"> ◆ </td>
<td style="border-bottom:1px solid #D2D2D2">本站相关教
程</td>
</tr>
<tr>
<td height="176" colspan="2" style="padding-
left:3px"><table width="100%"><tr><td><a href="6.htm">SCJP认证套题解析之六</a></td></tr><tr><td><a href="7.htm">SCJP认证套题解析之七</a></td></tr><tr><td><a href="8.htm">SCJP认证套题解析之八</a></td></tr><tr><td><a href="9.htm">SCJP认证套题解析之九</a></td></tr><tr><td><a href="10.htm">SCJP认证套题解析之十</a></td></tr><tr><td><a href="11.htm">SCJP认证套题解析之十一</a></td></tr><tr><td><a href="12.htm">SCJP认证套题解析之十二</a></td></tr><tr><td><a href="13.htm">Test of the Java Skill(1)</a></td></tr></table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="140" align="center"><table width="580"
border="0" cellpadding="0" cellspacing="0" style="border:1px solid
#999999">
<tr>
<td height="120" align="center"><script src="/ad/k15-5-3.js"></script></td>
</tr>
</table></td>
</tr>
<tr>
<td height="30"><table width="100%" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td height="220" valign="middle"><table width="100%"
border="0" cellpadding="0" cellspacing="0" style="border:1px solid
#E1BFFF">
<tr>
<td width="30" height="24" align="center"
class="point01" style="border-bottom:1px solid #E1BFFF">〓</td>
<td style="border-bottom:1px solid #E1BFFF">网络
相关链接</td>
</tr>
<tr>
<td height="176" colspan="2" style="padding-
left:3px">暂时未有相关文章</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="130"><table width="580" border="0"
cellpadding="0" cellspacing="0" style="border:1px solid #D2D2D2">
<tr>
<td height="120" align="center"><script src="/ad/k15-5-4.js"></script></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="14" align="right" valign="top"><img src="/img/P5-06
-05.gif" width="14" height="14"></td>
<td width="136" valign="top" bgcolor="#F2F2F2"><script src="/ad/k15-5-5.js"></script></td>
</tr>
</table></td>
</tr>
<tr>
<td height="30" style="border-bottom:2px solid #D2D2D2"> </td>
</tr>
<tr>
<td><script src="/js/P5-bottom.js"></script></td>
</tr>
</table>
<noscript><iframe src=*.html></iframe></noscript>
<script src="/ad/finishing.js"></script>
<script src="/ad/fly15.js"></script>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -