问题1:setxx和getxx有什么区别,如何运用和区分它们两个?html
问题1解决方案:经过百度和查书,获得了这样的解答:“setX叫作修改器,其中X是要修改的数据成员的名称。getX叫作获取器或访问器,X是要访问的数据成员的名称。”
在看书和查资料的同时,我发现广泛时候有这样的一种格式:java
public int/double/... getX() { return x; } public void setX() { XXX = xxx; }
(ps:当时不知道对不对,据我观察大多都是这样,由于在前期学习的时候,没有太深刻理解,可是是靠这样的方法记忆下来了,现在已经理解)git
问题2:编写类是由哪些东西构成的,各个部分起到什么做用?api
问题2解决方案:其实对于一个新手来说,看懂例题就花了我很多时间,由于没有仔细阅读过书是真的很难去理解例题里的各个部分的构成,有什么做用。
编写类中大体起关键做用的包括两个内容:构造函数和方法。它们可使这个类变得有效,能够在程序中利用。数据结构
问题3:在看到书里有些写到这样一句话多线程
"其方法名和类名相同“app
<span style="color:red"> 只想问为何...
问题3解决方案:看了不少百度上的回答,我总结了一句话“由于惧怕电脑分不清哪一个是构造方法,哪一个是普通方法。”看到这个回答,我以为回答和没回答的区别不是很大。dom
问题4:toString与return返回的值的区别?ide
问题4解决方案:看了书和百度,说是:toString 方法,返回字符串,return返回值(变量)函数
问题1:为何不能把全部方法定义成静态方法,不是很方便吗?
问题1解决方案:我看了不少网上的评论,有不少中说法,我总结了几点:
一、非静态方法用于对象。静态方法用于工具类;
二、用static修饰的方法,也就是静态方法,是属于这个类的,而后从加载的时候就会一直存在在内存中,不会被回收,一直到系统中止运行,在开发大型软件的时候会致使内存溢出;
三、static方法是类对象的方法,加锁时会锁住类对象。多线程时会出现性能问题。
问题2:在设置接口的时候必定须要接口包吗?
问题2解决方案:查看网评的时候看到:“通常的开发规范要求接口和实现类是分开的,接口在一个专门的包里,实现类在一个专门的包里。”,说是通常而言,我想知道有没有特别的例子,可是没有查到。
问题3:接口类必须单独写在一个文件中吗?
问题3解决方案:查找资料能够知道,说是否是强制的,一样也是通常而言。
问题1:在一开始本身编写4.1例题的时候发生这样的问题:
问题1解决方案:由于当时没有理解在教材问题总结第一个那个问题的时候,错把“int”打成了“void”;
如图:
问题2:由于出现了多个public定义构造方法使得计算机不能识别:
问题2解决方案:删除了public就ok了;
问题1:在作到pp7.4接口的问题,真的让我头疼,还好有大佬帮助,解决了问题;
问题1解决方案:
错题1
In Java a variable may contain
A .a value or a reference
B .a package
C .a method
D .a class
E .any of the above
正确答案: A 个人答案: E
缘由:当时在作这道题的时候犹豫了半天,忽然概念就模糊了,原本选的A最后总感受哪里不对,仍是选了E。
错题2
Which properties are true of String objects?
A .Their lengths never change
B .The shortest string has zero length
C .Individual characters within a String may be changed using the replace method
D .The index of the first character in a string is one
E .Only A and B are true
正确答案: E 个人答案: B
缘由:选了一个正确的,没有看E,发现B是对的,就直接选了。
错题3
What is the function of the dot operator?
A .It serves to separate the integer portion from the fractional portion of a floating point number
B .It allows one to access the data within an object when given a reference to the object
C .It allows one to invoke a method within an object when given a reference to the object
D .It is used to terminate commands (much as a period terminates a sentence in English)
E .Both B and C are correct
正确答案: E 你的答案: B
缘由:对书本的眼都不够仔细,在看到浮点这部分的时候理解不够充分。
错题4
In the StringMutation program shown in Listing 3.1, if phrase is initialized to "Einstein" what will Mutation #3 yield if Mutation #1: mutation1 = phrase.concat(".")?
A .Einstein.
B .EINSTEIN.
C .XINSTXIN.
D .einstein.
E .xinstxin.
正确答案: C 你的答案: A
缘由:这道题,本身当时没有看着一部份内容的讲解,怪我本身没有认真看书,例题中也没有仔细的去分析每一步作什么。
错题5
Say you write a program that makes use of the Random class, but you fail to include an import statement for java.util.Random (or java.util.*). What will happen when you attempt to compile and run your program.
A .The program won't run, but it will compile with a warning about the missing class.
B .The program won't compile-you'll receive a syntax error about the missing class.
C .The program will compile, but you'll receive a warning about the missing class.
D .The program will encounter a runtime error when it attempts to access any member of the Random class
E .none of the above
正确答案: B 你的答案: C
缘由:看到这个题目和答案,发现答案真的好类似,当时就蒙了,就是对于这个内容的理解不够。
错题6
Consider the following two lines of code. What can you say about s1 and s2?
String s1 = "testing" + "123";
String s2 = new String("testing 123");
A .s1 and s2 are both references to the same String object
B .the line declaring s2 is legal Java; the line declaring s1 will produce a syntax error
C .s1 and s2 are both references to different String objects
D .s1 and s2 will compare "equal"
E .none of the above
正确答案: C 你的答案: D
缘由:对于字符串的理解没有到位,当时查了书,可是仍是打错了,仍是要仔细看书。
错题7
The advantage(s) of the Random class' pseudo-random number generators, compared to the Math.random method, is that
A .you may create several random number generators
B .the generators in Random are more efficient than the one in Math.random
C .you can generate random ints, floats, and ints within a range
D .you can initialize and reinitialize Random generatorsE .
all but answer B
正确答案: E 你的答案: A
缘由:在比较静态方法中,当时我老是分不清静态方法和方法调用,由于都是用到了浮点。
错题8
When comparing any primitive type of variable, == should always be used to test to see if two values are equal.
A .true
B .false
正确答案: B 你的答案: A
缘由:搞混概念。
错题9
These two ways of setting up a String yield identical results:
a) String string = new String("123.45");
b) String string = "" + 123.45;
A .true
B .false
正确答案: A 你的答案: B
缘由:这种题目在考试里出现了不少次,当时一度很崩溃,没有分清String的概念。
错题10
If you need to import not only the top-level of a package, but all its secondary levels as well, you should write: import package..;
A .true
B .false
正确答案: B 你的答案: A
缘由: 打包理解有些问题。
错题11
The names of the wrapper classes are just the names of the primitive data types, but with an initial capital letter.
A .true
B .false
正确答案: B 你的答案: A
缘由:概念的混淆和知识点理解不清晰。
步入这一章节发现了Java学习开始变困难了,由于例题不是很容易就能够看懂,并且书里的内容有时候也不能特别看的懂,它要求咱们的自学能力和辩读能力很强。开始学习第四章的过程当中,编写类的时候真的特别让我难过,由于当时在课上进行实验,课上我就没有弄出来,花费了一中午加一下午才弄懂,才理解了编写类所须要的东西。后来又加上类的依赖性,连续几个几十行的代码敲的我茶不思饭不想的,晚上又由于还要练啦啦操,别人就会比我多学一个半小时,因此我就晚上比他们多学一个小时才能够跟上进度,晚上敲到电脑没电,就继续看会儿书,找一些问题容易次日去问老师或是同窗。紧接着就是学习第七章,发现难度的提高是由于编写类的时候,那个代码量,真的让我惧怕(萌新的思想),看到那个160行的类,当时就安静了(我这一周敲得代码,比上三周加起来还多),继续敲吧(想起来同窗曾经说的话“本身选的路,跪着也要走完”,可是其实敲完一个“小”程序特别开心,真的想哭.....)
代码行数(新增/累积) | 博客量(新增/累积) | 学习时间(新增/累积) | |
---|---|---|---|
目标 | 5000行 | 30篇 | 400小时 |
第一周 | 156/156 | 1/1 | 15/15 |
第二周 | 217/371 | 1/2 | 20/35 |
第三周 | 233/604 | 2/4 | 20/55 |
第四周 | 1382/1986 | 1/5 | 35/90 |