20172307 2017-2018-2 《程序设计与数据结构》第4周学习总结

20172307 2017-2018-2 《程序设计与数据结构》第4周学习总结

教材学习内容总结

本周学习了第4章,第7章。
第四章涉及到了自己编写类的一些方法,
第七章讲了类之间的关系,接口,方法的设计和重载等内容。
由于第七章有涉及前两章的内容也学习了5,6章的部分内容。

教材学习中的问题和解决过程

  • 问题1:对局部变量的定义看不太懂。
  • 问题1解决方案:通过网上的查阅,了解到局部变量是相对全局变量的,全局变量是在方法外声明的,但可以在方法中初始化。局部变量是在方法内声明,在方法内初始化。
  • 问题2:对接口的作用不太理解。
  • 问题2解决方案:通过同学的解释明白了接口在大型项目中作用很大,类似与一个规范,让做项目的人更好协调。

代码调试中的问题和解决过程

  • 问题1:在打7.4这个例子时出了很多错误
  • 问题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
    Java变量包含值或引用类的实例(其中包含值和/或额外的引用)。

  • If two variables contain aliases of the same object then
    A . the object may be modified using either alias
    B . the object cannot be modified unless there's but a single reference to it
    C . a third alias is created if/when the object is modified
    D . the object will become an "orphan" if both variables are set to null
    E . answers A and D are correct
    正确:E
    根据定义,一个对象的别名提供了一种方法可以修改。根据定义,一个对象的别名提供了一种方法可以修改。如果两个变量设置为null,那么对象没有引用任何变量(通过任何别名)和它,实际上,变成一个“孤儿”,它会被当作垃圾回收。

  • 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
    字符串是不可变的。这意味着一旦创建一个字符串对象就不能被改变。因此一个字符串一旦被创建长度不会改变。最短长度字符串是“没有字符之间的报价,所以长度是零。替代方法允许您创建一个新的字符串从一个原始,替换的字符。在字符串中第一个位置的索引是零。同时,每一个字符串包含的最后一个字节一个字节的字符串末尾字符的低价值,或二进制零。

  • 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
    失踪的类意味着会有未定义的变量和/或方法。编译器将检测这些错误,程序不会执行。

  • The advantages of the DecimalFormat class compared with the NumberFormat class include
    A . precise control over the number of digits to be displayed
    B . control over the presence of a leading zero
    C . the ability to truncate values rather than to round them
    D . the ability to display a % automatically at the beginning of the display
    E . only A and B
    正确:E
    A,B就是DecimalFormat的优势。

其他(感悟、思考等,可选)

这周确实觉得有些吃力,觉得有蛮多地方都是那种似懂非懂的状态,在敲代码的时候也很粗心,经常漏掉东西,以后要尽量注意吧。

学习进度条

代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
目标 5000行 30篇 400小时
第一周 200/200 2/2 20/20
第二周 300/500 2/4 18/38
第三周 500/1000 3/7 22/60
第四周 300/1300 2/9 30/90

参考资料

原文地址:https://www.cnblogs.com/20172307hyt/p/8719359.html