• 20182309 2019-2020-1 《数据结构与面向对象程序设计》第5周学习总结


    20182309 2019-2020-1 《数据结构与面向对象程序设计》第5周学习总结

    教材学习内容总结

    • 子类对父类的继承extends
    • 子类可以重写父类的方法
    • super调用父类的方法
    • 所有类都是从Object类继承来的
    • 抽象类abstract
    • 用protect修饰父类的变量和方法

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

    • 问题1:为什么需要protect修饰符
    • 问题1解决方案:为了在派生类中使用变量,但是要比public好

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

    • 问题1:statistics.sh出现问题
    xargs: cat:因信号 13 而终止
    

    • 问题1解决方案:这是因为存在它不认识的代码,删了就好。

    代码托管

    上周考试错题总结

    • 1.Aside from permitting inheritance, the visibility modifier protected is also used to

    A . permit access to the protected item by any class defined in the same package
    B . permit access to the protected item by any static class
    C . permit access to the protected item by any parent class
    D . ensure that the class can not throw a NullPointerException
    E . define abstract elements of an interface

    答案:A。被保护的可见性修饰符被用来以受保护(保护)的方式控制对该项的访问。保护措施是访问仅限于当前类(如私有项目)、同一包中的类或此类的扩展类。

    • 2.Which of the following is true regarding Java classes?

    A . All classes must have 1 parent but may have any number of children (derived or extended) classes
    B . All classes must have 1 child (derived or extended) class but may have any number of parent classes
    C . All classes must have 1 parent class and may have a single child (derived or extended) class
    D . All classes can have any number (0 or more) of parent classes and any number of children (derived or extended) classes
    E . All classes can have either 0 or 1 parent class and any number of children (derived or extended) classes

    答案:A。Java支持继承,但不支持多重继承,因此Java类可以有任意数量的子类,但只能有一个父类。此外,由于所有Java类都直接或间接从对象类继承,所以所有Java类都只有一个父类。

    • 3.Two children of the same parent class are known as

    A . aliases
    B . relatives
    C . clones
    D . brothers
    E . siblings

    答案:E。同一父母的两个孩子之间的关系被称为兄弟姐妹(兄弟会暗示性别)。克隆是同一个对象的副本,别名是同一个对象。兄弟和亲戚不被用来定义Java中类之间的关系。

    • 4.Using the reserved word, super, one can

    A . access a parent class'constructor(s)
    B . access a parent class'methods and instance data
    C . access a child class'constructor(s)
    D . access a child class'methods and instance data
    E . none of the above

    答案:E。super保留字提供了一种访问父类的方法和实例数据的机制(不管它们是否被隐藏)。此外,可以使用super访问父类的构造函数。所以正确答案是a和b的组合,这不是一个选项,所以正确答案是e。

    • 5.If you instantiate an Abstract class, the class or object you wind up with

    A . is also an Abstract class
    B . is a normal class
    C . is an Interface
    D . is a reference to an Object
    E . can't exist you cannot instantiate an Abstract class

    答案:E。你只能实例化具体的类而不是抽象的类。但是您可以扩展抽象类和接口。

    • 6.Interface classes cannot be extended but classes that implement interfaces can be extended.

    A . true
    B . false

    答案:B。任何类都可以扩展,无论它是接口、实现接口还是两者都不是。唯一的例外是类被显式地修改为“final”,在这种情况下它不能被扩展。

    • 7.A derived class has access to all of the methods of the parent class, but only the protected or public instance data of the parent class.

    A . true
    B . false

    答案:B。由于方法也可以声明为私有的,任何私有方法都不能被派生类访问。因此,派生类只能访问父类的受保护的公共方法和实例数据。

    • 8.Although classes can be inherited from one-another, even Abstract classes, interfaces cannot be inherited.

    A . true
    B . false

    答案:B。接口具有普通类所具有的所有继承属性。因此,您可以创建接口继承层次结构,就像创建类继承层次结构一样。但是,您不能做的是实例化一个必须实现的接口。

    结对及互评

    • 博客中值得学习的或问题:
    • 代码中值得学习的或问题:
      • 格式易看
    • 基于评分标准,我给本博客打分:10分。得分情况如下:
      • 正确使用Markdown语法(加1分)
      • 模板中的要素齐全(加1分)
      • 教材学习中的问题和解决过程, 一个问题加1分
      • 代码调试中的问题和解决过程, 一个问题加1分
      • 本周有效代码超过300分行的(加2分)
      • 排版精美的加一分
      • 代码Commit Message规范的加1分
      • 有动手写新代码的加1分
      • 结对学习情况真实可信的加1分

    点评过的同学博客和代码

    • 本周结对学习情况
      • 20182331
      • 结对学习内容
        • 建立局域网下服务器与客户端的连接
        • 学习继承关系
        • 解决代码错误

    学习进度条

    代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
    目标 10000行 30篇 400小时
    第一周 138/138 2/2 25/25 学会写和上传代码,会编简单的输出程序
    第二周 88/226 1/3 30/55 起文件名不能太长
    第三周 898/1124 2/5 35/90 Java类里面的方法和C语言的函数很像
    第四周 632/1756 2/7 30/120 可以用继承extends简化重复的代码
    第五周 770/2526 2/9 45/165 --amend -m可以重命名没push的文件

    参考资料

  • 相关阅读:
    各种alloc傻傻分不清楚
    嵌入式开发一般流程
    谈谈看门狗在嵌入式中的用法
    基于开发板的二次嵌入式开发
    谈一谈接口电路
    学习ucos和ARM体系结构的路线图
    寻找链表的中位节点(利用快慢指针)
    水箱容积问题
    盛水最多的容器
    数据结构与算法分析C语言描述第二版第79页
  • 原文地址:https://www.cnblogs.com/blueflameashe/p/11629472.html
Copyright © 2020-2023  润新知