OCJP (1Z0-808) 个人笔记(1)

本文深入探讨了Java编程中的常见问题及解决方案,包括变量作用域、异常处理、构造函数调用、循环控制等内容,并提供了实用的编码建议。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//仅为个人笔记,目前完善中


1.static变量count为Test类中所有方法共有,两次changeCount使count最终为10,check1.count=check2.count。

2.本题product.toLowerCase()与product.concat("BOX".toLowerCase())均可实现,但实现后并没有保存到一个参数中。product最后存放的依然是Pen,仅有0,2三个字符,substring范围为4,6,超出范围,String index out of range。

3.java异常机制的三个优势:

  1. 改进项目结构,分离错误处理代码与正常函数。
  2. 选择处理错误的位置。
  3. 自定义异常。

4.line n1中的this()为调用无参构造函数,而在创建了一个有参的构造函数的时候,系统自带的无参构造函数被取消,无法调用,所以报错,lin n2中的Person(name)为调用Person方法,下面无person方法,报错。

5.B中的findMid参数应为n1,n2,且在static的main函数中无法使用super,E中没有创建实例便调用非静态方法。

6.各种date

7-9.略。

10.Java封装的处理。get函数用return直接返回数值即可。A选项似乎是反射?这题没看懂。

11.row在循环外,col从循环中出来时值为-2。若为0,会报错。

12.indexOf为找出ArrayList中元素的位置,插入默认首位为0。

13.super调用函数为super.方法,super()调用父类元素。可用于调用在子类被重载的父类方法。

14.D for循环中的第三个语句并不一定需要填写,可以为空。

15.存疑

16.

17.for(int element:iArray)循环语句的作用     (对于二维数组不适用,会出现乱码?没有详细研究。)

    int[] a={1,2,3,4,5,6};

    for(int e:a) //依次取出数组a中的元素赋给变量e
    {
    System.out.println(e); //输出e
    }
    输出结果:
    1
    2
    3
    4
    5

    6

18.其实什么都不加也是可以编译和运行的,可能是题目写的意思不好,应为哪两个改动可以让程序按照switch语句的意图运行。

default可加可不加,D选项只改变day的属性不够,还要把day的1改成“1”。E选项顺序对switch语句无影响。

19.p1,p2分别创建了两个product,存放在内存中不同区块,p3=p1,是让p3指向p1区块。

==判断的是内存地址是否相同,equals判断的是值是否相同。

这句的运行结果是false,在对象间equals比较的也是内存地址,而非两者的值是否相同。

20.先new了三个ref,最后再进行打印。第三个ref3并没有通过if语句检查,ns值为初始值0。

21.D

22.三目运算符基础,略。

23-24.略

25.我实际在eclipse上运行,B选项也并没有错误。

26.这题比较没意思,他的while循环后面是; 没有用{}来括住后面的print语句,所以while死循环了。如果括住,每轮循环i会置1,输出为1  12  123

27.略

28.concat和replace的用法。第六行中它并没有把ta.replace赋值给ta,ta依然为A B C,如果赋值给ta,ta的值会变为A B D

29.

30.没有定义的方法格式,编译不通过。

Title: OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 Author: Jeanne Boyarsky, Scott Selikoff Length: 432 pages Edition: 1 Language: English Publisher: Sybex Publication Date: 2014-12-31 ISBN-10: 1118957407 ISBN-13: 9781118957400 Full coverage of functional programming and all OCA Java Programmer exam objectives OCA, Oracle Certified Associate Java SE 8 Programmer I Study Guide, Exam 1Z1-808 is a comprehensive study guide for those taking the Oracle Certified Associate Java SE 8 Programmer I exam (1Z1-808). With complete coverage of 100% of the exam objectives, this book provides everything you need to know to confidently take the exam. The release of Java 8 brought the language's biggest changes to date, and for the first time, candidates are required to learn functional programming to pass the exam. This study guide has you covered, with thorough functional programming explanation and information on all key topic areas Java programmers need to know. You'll cover Java inside and out, and learn how to apply it efficiently and effectively to create solutions applicable to real-world scenarios. * Work confidently with operators, conditionals, and loops * Understand object-oriented design principles and patterns * Master functional programming fundamentals Table of Contents Chapter 1 Java Building Blocks Chapter 2 Operators and Statements Chapter 3 Core Java APIs Chapter 4 Methods and Encapsulation Chapter 5 Class Design Chapter 6 Exceptions Appendix A Answers to Review Questions Appendix B Study Tips
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值