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


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

    教材学习内容总结

    第四章:

    • 学习了如何编写类;
    • 了解类的构成与用途;
    • 理解了各个数据的不同和其各自特点;
    • 学习了很多新的语句和方法;

    第七章:

    • 了解了静态变量和静态的方法;
    • 类与类之间的关系和关联性;
    • 相比于之前实例数据的引用增添了“this”语句的引用;
    • 学习了如何在编写类中加上接口,并且学习了几个接口如何运用;
    • 知道了编写程序所需要的几个步骤;

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

    第四章:

    • 问题1:setxx和getxx有什么区别,如何运用和区分它们两个?

    • 问题1解决方案:通过百度和查书,得到了这样的解答:“setX叫做修改器,其中X是要修改的数据成员的名称。getX叫做获取器或访问器,X是要访问的数据成员的名称。”
      在看书和查资料的同时,我发现普遍时候有这样的一种格式:

        public int/double/... getX()
        {
        return x;
        }
        public void setX()
        {
        XXX = xxx;
        }
      

      (ps:当时不知道对不对,据我观察大多都是这样,因为在前期学习的时候,没有太深入理解,但是是靠这样的方法记忆下来了,如今已经理解)

    • 问题2:编写类是由哪些东西构成的,各个部分起到什么作用?

    • 问题2解决方案:其实对于一个新手来讲,看懂例题就花了我不少时间,因为没有仔细阅读过书是真的很难去理解例题里的各个部分的构成,有什么作用。
      编写类中大致起关键作用的包括两个内容:构造函数和方法。它们可以使这个类变得有效,可以在程序中利用。

    • 问题3:在看到书里有些写到这样一句话

    "其方法名和类名相同“

      <span style="color:red">  只想问为什么...
    
    • 问题3解决方案:看了很多百度上的回答,我总结了一句话“因为害怕电脑分不清哪个是构造方法,哪个是普通方法。”看到这个回答,我觉得回答和没回答的区别不是很大。

    • 问题4:toString与return返回的值的区别?

    • 问题4解决方案:看了书和百度,说是:toString 方法,返回字符串,return返回值(变量)

    第七章:

    问题1:为什么不能把所有方法定义成静态方法,不是很方便吗?
    问题1解决方案:我看了很多网上的评论,有很多中说法,我总结了几点:
    1、非静态方法用于对象。静态方法用于工具类;
    2、用static修饰的方法,也就是静态方法,是属于这个类的,然后从加载的时候就会一直存在在内存中,不会被回收,一直到系统停止运行,在开发大型软件的时候会导致内存溢出;
    3、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

    参考:

    Java程序设计

  • 相关阅读:
    python基础:8.正则表达式
    [Unity工具]批量修改字体
    产品理念(微博和Twitter)
    个性化推荐技术漫谈
    谱聚类算法(转自http://www.cnblogs.com/vivounicorn/archive/2012/02/10/2343377.html)
    Ubuntu输入正确密码后无法登录
    KMeans java实现(未用Hadoop版改进)
    Nutch安装指南
    KMeans的MapReduce实现
    特征向量的几何意义
  • 原文地址:https://www.cnblogs.com/qh45wangwenbin/p/8716668.html
Copyright © 2020-2023  润新知