OOP

作者: 我是阿喵酱 | 来源:发表于2018-02-04 16:36 被阅读0次

Great work! Let's review everything that we've learned about object-oriented programming in Java so far.

  • Class: a blueprint for how a data structure should function
  • Constructor: instructs the class to set up the initial state of an object
  • Object: instance of a class that stores the state of a class
  • Method: set of instructions that can be called on an object
  • Parameter: values that can be specified when creating an object or calling a method
  • Return value: specifies the data type that a method will return after it runs
  • Inheritance: allows one class to use functionality defined in another class

Instance
Mouse.java

public class Mouse extends Rodentia {

    String name;

    public Mouse(String name) {

        this.name = name;

    }

    public void eat() {

        System.out.println(name + " ate some cheese pizza!");

    }

    public void solveMaze(int minutes) {

        System.out.println(name + " solved the maze in " + minutes + " minutes!");

    }

    public static void main(String[] args) {

        Mouse ratly = new Mouse("Ratly");
        ratly.eat();
        ratly.solveMaze(3);
        ratly.order();

    }

}

Rodentia.java

public class Rodentia {

    public static void main(String[] args) {

    }

    public void order() {

        System.out.println("This animal belongs to the Rodentia order.");

    }

}

相关文章

  • OOP

    oop_simplestclass.py oop_methond.py oop_init.py oop_objva...

  • 关于oop和aop

    oop oop(Object Oriented Programming)面向对象编程, oop的设计特征:封装, ...

  • 面向对象编程

    OOP 指什么?有哪些特性 OOP:OOP(Object-oriented programming, 面向对象编程...

  • 关于对象-原型

    1.OOP 指什么?有哪些特性 OOP:Object-oriented programming,缩写OOP,即面向...

  • Java面试总结

    1.什么是OOP、AOP OOP即面向对象编程OOP三大特征:封装、继承、多态OOP五大原则:单一职责原则 (Si...

  • OOP

    类定义 说明:init为构造函数,第一个参数为self为函数本身。类成员以双下划线开头,说明为private访问限...

  • OOP

    java in think 起因 自从买了Java in think 这本书,一直想认真仔细的品味下这本某种意义的...

  • oop

    面向对象基本操作:一:基本操作示例一: class Test_A(): #定义类名def A(self):...

  • OOP

  • OOP

    Great work! Let's review everything that we've learned ab...

网友评论

      本文标题:OOP

      本文链接:https://www.haomeiwen.com/subject/movbkxtx.html