zoukankan      html  css  js  c++  java
  • 课后总结

    package TestInherits;
    //继承问题及super的用法
    class Grandparent { public Grandparent() { System.out.println("GrandParent Created."); } public Grandparent(String string) { System.out.println("GrandParent Created.String:" + string); } } class Parent extends Grandparent { public Parent() { //super("Hello.Grandparent."); System.out.println("Parent Created"); // super("Hello.Grandparent."); } } class Child extends Parent { public Child() { System.out.println("Child Created"); } } public class TestInherits { public static void main(String args[]) { Child c = new Child(); } }

    1.未取消注释时的结果:

    2.将第一个注释取消时的输出结果:

    3.将第二个注释取消,程序会报错:

    结论:通过 super 调用基类构造方法,必须是子类构造方法中的第一个语句。

    子类的构造方法在运行之前,必须调用父类的构造方法

    原因:构造函数的主要作用是初始化。

    不可变类:final

     final即最完美的,最终的,不可更改。

    奇怪的输出:

    package text;
    
    public class text {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            System.out.println(new A());
        }
    
    }
    package text;
    
    public class A {
    
    }

    输出结果:

    探索步骤:

    自我抑郁又自我救赎
  • 相关阅读:
    bash task list and interrupt
    bash字符串大小写转换方法
    Spectrum Mask
    OFDM中CP的优缺点
    模块边界使用寄存器来做数据的交互
    跨时钟域信号处理
    FPGA中一个Slice所含资源
    Verilog中if-else改写成case的方法
    同步序列的自相关与互相关
    TCP三次握手四次挥手
  • 原文地址:https://www.cnblogs.com/zjm15511858030/p/9890525.html
Copyright © 2011-2022 走看看