📄 scjp认证套题解析之二.htm
字号:
<HTML>
<HEAD>
<TITLE>《SCJP认证套题解析之二》-JAVA中文站(www.java-cn.com)</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="resources/style.css" rel=stylesheet>
<STYLE type=text/css>
TD {FONT-SIZE: 9pt; FONT-FAMILY: 宋体}
TH {FONT-SIZE: 9pt; FONT-FAMILY: 宋体}
INPUT {FONT-SIZE: 9pt; FONT-FAMILY: 宋体}
.menuStyle {FONT-WEIGHT: bold; FONT-SIZE: 9pt; FONT-FAMILY: Arial,Geneva,Verdana,Helvetica}
</STYLE>
<SCRIPT language=javascript src="resources/to.js"></SCRIPT>
<SCRIPT language=javascript src="resources/window.js"></SCRIPT>
<SCRIPT language=JScript>
function turnit(ii,ss)
{
if (ss.style.display=="none")
{ss.style.display="";
ii.src="images/icon_minus.gif";
}
else
{ss.style.display="none";
ii.src="images/icon_plus.gif";}
}
</SCRIPT>
<META content="Microsoft FrontPage 6.0" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV align=center>
<CENTER>
<br>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#111111 cellSpacing=0 cellPadding=0 width=760 border=0 height="149">
<TBODY>
<TR bgColor=#FFFFFF>
<TD style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid" align=middle height=34 width="760" colspan="2">
<DIV align=center>
<iframe src="detail_broadcast.htm" scrolling="no" width=728 height=90 marginwidth=0 marginheight=0 frameborder="no"></iframe>
</DIV>
</TD>
</TR>
<tr>
<TD style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-TOP: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid; BORDER-BOTTOM: #c0c0c0 1px solid" vAlign=top width="760" height=11 colspan="2">
<p align="left">
<font color="#7A7978">文章类型>> </font>
<font color="#999999">
认证考试
|</font>
<font color="#7A7978">阅读次数>> </font>
<font color="#999999">528 |</font>
<font color="#7A7978">得分>> </font>
<font color="#999999">0 |</font>
<font color="#7A7978">整理日期>> </font>
<font color="#999999">2005-01-26 |</font>
<font color="#7A7978">整理发布>> </font>
<font color="#999999">rayjrb</font> |</font>
<a href="#remark"><font style="COLOR: #ff0000; TEXT-DECORATION: none">评论评分</font></a><img src="images/new9.gif">
</TD>
</tr>
<TR bgColor=#f3fcf3>
<TD style="border:1px solid #C0C0C0; " align=center width=760 height=38 bgcolor="#FFFFFF" colspan="2">
<table border="0" width="100%" id="table1" height="41">
<tr>
<td><b><center>SCJP认证套题解析之二</center></b><hr noshade color="#999999" size="1"><p align="left">
21、Which of the following assignment is not correct?
<br> A. float f = 11.1;
<br> B. double d = 5.3E12;
<br> C. double d = 3.14159;
<br> D. double d = 3.14D.
<br> (a)
<br> 题目:下面的哪些赋值语句是不对的。
<br> 浮点数的赋值是带有小数点的数字缺省是double型的,如果在浮点数后面加f或者F则是float,后面加d或者D则是double,科学计数法形式的浮点数也是double型的,而double的精度比float高,将一个高精度的double赋值给一个低精度的float时需要进行强制类型转换,反之则不需要。
<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 =
<br> a; }
<br> public Person(String n, String d, int a) {
<br> // doing the same as two arguments version of
<br> constructor
<br> // including assignment name=n,age=a
<br> department = d;
<br> }
<br> }
<br> Which expression can be added at the "doing the same
<br> as..." part of the constructor?
<br> A. Person(n,a);
<br> B. this(Person(n,a));
<br> C. this(n,a);
<br> D. this(name,age).
<br> (c)
<br> 题目:给出下面的不完整的类代码:
<br> …
<br> 下面的哪些表达式可以加到构造方法中的"doing the same as..."处?
<br> 在同一个类的不同构造方法中调用该类的其它构造方法需要使用this(…)的形式,而且必须是在构造方法的第一行调用,这个和普通的方法重载调用的方式不同,普通的方法可以直接使用方法名加参数来调用,而且调用位置没有限制,因此答案A是不行的,B的语法就是错误的,D的错误在于在父类型的构造函数被调用前不能引用类的成员。构造方法是一个类对象实例化的起点(虽然严格来说首先执行的并不是构造方法的第一个语句,而是内存的分配),因此在构造方法中不能将成员作为参数引用。
<br>
<br> 23、Which of the following statements about variables and
<br> their scopes are true?
<br>
<br> A. Instance variables are member variables of a class.
<br> B. Instance variables are declared with the static
<br> keyword.
<br> C. Local variables defined inside a method are created
<br> when the method is executed.
<br> D. Local variables must be initialized before they are
<br> used.
<br> (acd)
<br> 题目:下面关于变量及其范围的陈述哪些是对的。
<br> A. 实例变量是类的成员变量。
<br> B. 实例变量用关键字static声明。
<br> C. 在方法中定义的局部变量在该方法被执行时创建
<br> D. 局部变量在使用前必须被初始化。
<br> 类中有几种变量,分别是:局部变量(英文可以为:local\automatic\temporary\stack
<br> variable)是定义在方法里的变量;实例变量(英文为:instance
<br> variable)是在方法外而在类声明内定义的变量,有时也叫成员变量;类变量(英文为:class
<br> variable)是用关键字static声明的实例变量,他们的生存期分别是:局部变量在定义该变量的方法被调用时被创建,而在该方法退出后被撤销;实例变量在使用new
<br> Xxxx()创建该类的实例时被创建,而其生存期和该类的实例对象的生存期相同;类变量在该类被加载时被创建,不一定要用new
<br> 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> Which will display if oneMethod run normally?
<br> A. condition 1
<br> B. condition 2
<br> C. condition 3
<br> D. finally
<br> (ad)
<br> 题目:在oneMethod()方法运行正常的情况下将显示什么?
<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> C. The value is 10
<br> D. The value is 11
<br> (c)
<br> 题目:给出下面的代码:
<br> …
<br> 输出将是什么?
<br> 此题考察的是do… while循环和 --
<br> 操作符的知识,do…while最少被执行一次,在执行完do中的内容后判断while中的条件是否为true,如果为true的话就再执行do中的内容,然后再进行判断,以此类推直到while的判断为false时退出循环执行循环后面的内容,而?操作符的规则是在变量右边的
<br> -- 将先进行运算,然后才是使变量的值减一,而在变量左边的是先将变量的值减一再运算。
<br>
<br> 26、Which of the following statements about declaration
<br> are true?
<br> A. Declaration of primitive types such as boolean, byte
<br> and so on does not allocate memory space for the
<br> variable.
<br> B. Declaration of primitive types such as boolean, byte
<br> and so on allocates memory space for the variable.
<br> C. Declaration of nonprimitive types such as String,
<br> Vector and so on does not allocate memory space for the
<br> object.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -