ImageVerifierCode 换一换
格式:DOCX , 页数:10 ,大小:19.37KB ,
资源ID:25056870      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/25056870.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(JAVA认证历年真题SCJP认证套题解析2.docx)为本站会员(b****9)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

JAVA认证历年真题SCJP认证套题解析2.docx

1、JAVA认证历年真题SCJP认证套题解析2 JAVA认证历年真题:SCJP认证套题解析2JAVA认证历年真题:SCJP认证套题解析2JAVA认证历年真题:SCJP认证套题解析221、which of the following assignment is not correct? a. float f = 11.1; b. double d = 5.3e12; c. double d = 3.14159; d. double d = 3.14d. (a) 题目:下面的哪些赋值语句是不对的。 浮点数的赋值是带有小数点的数字缺省是double型的,如果在浮点数后面加f或者f则是float,后面加d

2、或者d则是double,科学计数法形式的浮点数也是double型的,而double的精度比float高,将一个高精度的double赋值给一个低精度的float时需要进行强制类型转换,反之则不需要。 22、given the uncompleted code of a class: class person string name, department; int age; public person(string n) name = n; public person(string n, int a) name = n; age = a; public person(string n, stri

3、ng d, int a) / doing the same as two arguments version of constructor / including assignment name=n,age=a department = d; which expression can be added at the doing the same as. part of the constructor? a. person(n,a); b. this(person(n,a); c. this(n,a); d. this(name,age). (c) 题目:给出下面的不完整的类代码: 下面的哪些表

4、达式可以加到构造方法中的doing the same as.处? 在同一个类的不同构造方法中调用该类的其它构造方法需要使用this( )的形式,而且必须是在构造方法的第一行调用,这个和普通的方法重载调用的方式不同,普通的方法可以直接使用方法名加参数来调用,而且调用位置没有限制,因此答案a是不行的,b的语法就是错误的,d的错误在于在父类型的构造函数被调用前不能引用类的成员。构造方法是一个类对象实例化的起点(虽然严格来说首先执行的并不是构造方法的第一个语句,而是内存的分配),因此在构造方法中不能将成员作为参数引用。 23、which of the following statements abou

5、t variables and their scopes are true? a. instance variables are member variables of a class. b. instance variables are declared with the static keyword. c. local variables defined inside a method are created when the method is executed. d. local variables must be initialized before they are used. (

6、acd) 题目:下面关于变量及其范围的陈述哪些是对的。 a. 实例变量是类的成员变量。 b. 实例变量用关键字static声明。 c. 在方法中定义的局部变量在该方法被执行时创建 d. 局部变量在使用前必须被初始化。 类中有几种变量,分别是:局部变量(英文可以为:localautomatictemporarystack variable)是定义在方法里的变量;实例变量(英文为:instance variable)是在方法外而在类声明内定义的变量,有时也叫成员变量;类变量(英文为:class variable)是用关键字static声明的实例变量,他们的生存期分别是:局部变量在定义该变量的方法被

7、调用时被创建,而在该方法退出后被撤销;实例变量在使用new xxxx()创建该类的实例时被创建,而其生存期和该类的实例对象的生存期相同;类变量在该类被加载时被创建,不一定要用new xxxx()创建,所有该类的实例对象共享该类变量,其生存期是类的生存期。任何变量在使用前都必须初始化,但是需要指出的是局部变量必须显式初始化,而实例变量不必,原始类型的实例变量在该类的构造方法被调用时为它分配的缺省的值,整型是0,布尔型是false,而浮点型是0.0f,引用类型(类类型)的实例变量的缺省值是null(没有进行实际的初始化,对它的使用将引起nullpointexception),类变量的规则和实例变量

8、一样,不同的是类变量的初始化是在类被加载时。24、public void test() try onemethod(); system.out.println(condition 1); catch (arrayindexoutofboundsexception e) system.out.println(condition 2); catch(exception e) system.out.println(condition 3); finally system.out.println(finally); which will display if onemethod run normall

9、y? a. condition 1 b. condition 2 c. condition 3 d. finally (ad) 题目:在onemethod()方法运行正常的情况下将显示什么? 如果try块中的语句在执行时发生异常,则执行从该处中断而进入catch块,根据异常的类型进行匹配,最前面的优先进行匹配比较,只要该异常是catch中指定的异常的子类就匹配成功进而执行相应的catch中的内容,而finally块中的内容无论是否发生异常都将被执行。 25、given the following code: public class test void printvalue(int m) do

10、 system.out.println(the value is+m); while( -m 10 ) public static void main(string arg) int i=10; test t= new test(); t.printvalue(i); which will be output? a. the value is 8 b. the value is 9 c. the value is 10 d. the value is 11 (c) 题目:给出下面的代码: 输出将是什么? 此题考察的是do while循环和 - 操作符的知识,do while最少被执行一次,在执

11、行完do中的内容后判断while中的条件是否为true,如果为true的话就再执行do中的内容,然后再进行判断,以此类推直到while的判断为false时退出循环执行循环后面的内容,而?操作符的规则是在变量右边的 - 将先进行运算,然后才是使变量的值减一,而在变量左边的是先将变量的值减一再运算。 26、which of the following statements about declaration are true? a. declaration of primitive types such as boolean, byte and so on does not allocate me

12、mory space for the variable. b. declaration of primitive types such as boolean, byte and so on allocates memory space for the variable. c. declaration of nonprimitive types such as string, vector and so on does not allocate memory space for the object. d. declaration of nonprimitive types such as st

13、ring, vector ans so on allocates memory space for the object. (ad) 题目:下面的有关声明的哪些叙述是对的。 a. 对原始数据类型例如boolean,byte的变量的声明不会为该变量分配内存空间。 b. 对原始数据类型例如boolean,byte的变量的声明将为之分配内存空间。 c. 非原始数据类型例如string,vector的变量的声明不会为该对象分配内存。 d. 非原始数据类型例如string,vector的变量的声明会为该对象分配内存。 对原始数据类型的变量的声明将为之分配内存并赋予一个缺省值,参见23题的叙述,而非原始数

14、据类型的变量必须用new xxxx()分配内存及初始化。但是严格来讲此题的答案有待确定,因为只有原始类型的实例变量和类变量的声明在类对象被创建/类被加载时完成内存的自动分配,而原始类型的局部变量必须显式初始化,从这点来看原始类型的局部变量没有被自动分配内存,sl275中只提出了非原始数据类型的变量必须使用new xxxx()完成内存的分配而没有指出原始数据类型的变量是否在声明时即自动进行内存分配,而从局部变量不能在显式初始化前使用这点来看在声明时没有进行内存分配。因此答案a的正确性还有待官方的确定。27、in the java api documentation which sections

15、are included in a class document? a. the description of the class and its purpose b. a list of methods in its super class c. a list of member variable d. the class hierarchy (acd) 题目:在java api文档中下面的哪些部分被包括在内 a. 类及用途的描述 b. 父类的方法的列表 c. 成员变量的列表 d. 类层次 类文档的内容主要是:类层次、类及用途描述、成员变量列表、构造方法列表、成员方法列表、从类层次上继承的方

16、法列表、成员变量的详细说明、构造方法详细说明、成员方法详细说明。 28、given the following code: 1) public void modify() 2) int i, j, k; 3) i = 100; 4) while ( i 0 ) 5) j = i * 2; 6) system.out.println ( the value of j is + j ); 7) k = k + 1; 8) i-; 9) 10) which line might cause an error during compilation? a. line 4 b. line 6 c. lin

17、e 7 d. line 8 (c) 题目:给出下面的代码: 哪些行在编译时可能产生错误。 这个问题在前面有关变量的类型及其作用域的问题中讨论过,局部变量在使用前必须显式初始化,而代码中的变量k在使用前没有。 29、which of the following statements about variables and scope are true? a. local variables defined inside a method are destroyed when the method is exited. b. local variables are also called auto

18、matic variables. c. variables defined outside a method are created when the object is constructed. d. a method parameter variable continues to exist for as long as the object is needed in which the method is defined. (abc) 题目:下面有关变量及其作用域的陈述哪些是对的。 a. 在方法里面定义的局部变量在方法退出的时候被撤销。 b. 局部变量也叫自动变量。 c. 在方法外面定义

19、的变量(译注:即实例变量)在对象被构造时创建。 d. 在方法中定义的方法的参变量只要该对象被需要就一直存在。 本题还是讨论变量的类型及作用域,参看前面的叙述。 30、a class design requires that a member variable cannot be accessible directly outside the class. which modifier should be used to obtain the access control? a. public b. no modifier c. protected d. private (d) 题目:类的设计要

20、求它的某个成员变量不能被外部类直接访问。应该使用下面的哪些修饰符获得需要的访问控制。 这个在前面也有叙述,java有四种访问类型,分别为:public,protected,default,private,其中public变量可以被所有的外部类访问,而pretected的可以被同一个包及该类的子类访问,default即没有任何修饰符的变量可以被同一个包中的类访问,而private变量只能在被该类内部被访问。题目中的外部类应该理解为除该类自身的所有其它类,因此只有使用private可以达到要求。31given the following code fragment: 1) string str =

21、 null; 2) if (str != null) (str.length() 10) 3) system.out.println(more than 10); 4) 5) else if (str != null) (str.length() 5) 6) system.out.println(less than 5); 7) 8) else system.out.println(end); which line will cause error? a. line 1 b. line 2 c. line 5 d. line 8 (c) 题目:给出下面的代码片断: 哪些行将导致错误。 此题需要

22、将代码仔细看清楚,查询没有逻辑错误,if else的使用没有问题,也没有拼写错误,错误在于第5行的 与 操作符的使用,逻辑操作符(logical operator)的 与 应该是 ,而在执行 与 操作的时候,如果第一个条件为false,那么第二个条件判断运算是不做的,但是这里是位逻辑操作符(bitwise logical operator)的 与 ,在进行这个运算时,无论第一个条件的结果是什么都会执行第二个的运算,因此,假设str=null,那么第5句的str.length()就会导致nullpointerexception,因此本题的错误在于此。 32、which statements ab

23、out java code security are true? a. the bytecode verifier loads all classes needed for the execution of a program. b. executing code is performed by the runtime interpreter. c. at runtime the bytecodes are loaded, checked and run in an interpreter. d. the class loader adds security by separating the

24、 namespaces for the classes of the local file system from those imported from network sources. (bcd) 题目:下面有关java代码安全性的叙述哪些是对的。 a. 字节码校验器加载查询执行需要的所有类。 b. 运行时解释器执行代码。 c. 在运行时,字节码被加载,验证然后在解释器里面运行。 d. 类加载器通过分离本机文件系统的类和从网络导入的类增加安全性。 sl275中描述的java程序运行的过程是这样的:类加载器(class loader)加载程序运行所需要的所有类,它通过区分本机文件系统的类和网络系统导入的类增加安全性,这可以限制任何的特洛伊木马程序,因为本机类总是先被加载,一旦所有的类被加载完,执行文件的内存划分就固定了,在这个时候特定的内存

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1