zoukankan      html  css  js  c++  java
  • ********2019-2020-1 《数据结构与面向对象程序设计》第五学习总结

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

    教材学习内容总结

    1. 什么是继承:
    • 继承就是子类继承父类的特征和行为,使得子类对象(实例)具有父类的实例域和方法,或子类从父类继承方法,使得子类具有父类相同的行为。2. 继承的语法关键字 extends 表明正在构造的新类派生于一个已存在的类。已存在的类被称为超类(super class)、基类(base class)或父类(parent class);新类被称为子类(subclass)

      super 关键字有两个用途:一是调用超类的方法,二是调用超类的构造器。super 不是一个对象的引用,不能将 super 赋给另一个对象变量,它只是一个指示编译器调用超类方法的特有关键字。
    1. 继承初始化过程:
    • 父类的静态变量-->父类的静态代码块-->子类的静态变量-->子类的静态代码快-->父类的非静态变量(父类的非静态代码块)-->父类的构造函数-->子类的非静态变量(子类的非静态代码块)-->子类的构造函数
    • 父类的非静态变量(父类的非静态代码块)是同一级的,看哪个部分写在类的最前面谁就先被执行,子类的非静态变量(子类的非静态代码块)也是一样。
      【图片】
      3.继承的优缺点:
    • 在面向对象语言中,继承是必不可少的、非常优秀的语言机制,它有如下优点:
      • 代码共享,减少创建类的工作量,每个子类都拥有父类的方法和属性;
      • 提高代码的重用性;
      • 子类可以形似父类,但又异于父类;
        提高代码的可扩展性,实现父类的方法就可以“为所欲为”。
      • 提高产品或项目的开放性。

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

    • 问题一:Exception in thread "main"java.lang.NullPointerException
      • 问题一解决方案:定义数组后有对每个数组对象进行实例化。

    代码托管

    截图

    1.In order to preserve encapsulation of an object, we would do all of the following except for which one?

    A .Make the instance data private

    B .Define the methods in the class to access and manipulate the instance data

    C .Make the methods of the class public

    D .Make the class final

    E .All of the above preserve encapsulation

    理解:D一定是错误的,如果把类设置成final,它就不能被重写,子类一直都会是抽象类,不能实例化
    2.An example of passing message to a String where the message has a String parameter would occur in which of the following messages?

    A .length

    B .substring

    C .equals

    D .toUpperCase

    E .none of the above, it is not possible to pass a String as a parameter in a message to a String```

    理解:length和toUpperCase没有参数,substring需要两个int型参数,equals需要一个String类型的参数

    3.What happens if you declare a class constructor to have a void return type?

    A .You'll likely receive a syntax error

    B .The program will compile with a warning, but you'll get a runtime error

    C .There's nothing wrong with declaring a constructor to be void

    D .The class' default constructor will be used instead of the one you're declaring

    E .None of the above

    理解:构造方法没有返回类型,没有void,不能返回任何值,定义类型为void会收到语法错误的报错

    反思:

    本周实验及其难搞,还需努力。

    结对及互评

    参考资料

    ㅤ| 代码行数(新增/累积) | 博客量(新增/累积)|学习时间(新增/累积)|重要成长
    ---|---|---|---|---
    目标 |10000行| 30篇 |400小时| ㅤ
    第一周 |138/138|2/2|23/23|减少了鼠标的使用次数
    第二周 |749/887|1/4|25/48|对JAVA感触加深
    第三周 |765/1652|1/4|25/48|对JAVA感触加深
    第四周 |694/2346|1/6|20/87 |学会了类
    第五周 |1659/4005 | 1/8 | 21/108 |

  • 相关阅读:
    (IOCP)-C#高性能Socket服务器的实现
    GraphQL和RESTful的区别
    HTTP Client Performance Improvements
    foobar2000 iOS使用,并连接PC的歌曲进行播放
    Spring中基于AOP的@AspectJ
    Spring中基于AOP的XML架构
    Spring框架的AOP
    Spring的AOP AspectJ切入点语法详解(转)
    Spring中实现自定义事件
    Spring的事件处理
  • 原文地址:https://www.cnblogs.com/Stark-GR/p/11632611.html
Copyright © 2011-2022 走看看