Changes between Version 4 and Version 5 of jazz/21-09-22


Ignore:
Timestamp:
Oct 7, 2021, 4:32:46 PM (3 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • jazz/21-09-22

    v4 v5  
    1919
    2020- [[Image(OOP_Concepts.png)]]
     21
     22{{{
     23#!java
     24public class HelloWorld{
     25
     26     public static void main(String []args){
     27        System.out.println("Hello World");
     28       
     29        Animal a = new Cat();
     30        Animal b = new Kitten();
     31       
     32        a.who_am_i();
     33        b.who_am_i();
     34     }
     35}
     36
     37abstract class Animal {
     38    abstract void who_am_i();
     39}
     40
     41class Cat extends Animal {
     42    void who_am_i() {
     43        System.out.println("I'm a Cat");
     44    }
     45}
     46
     47class Kitten extends Cat {
     48    void who_am_i() {
     49        System.out.println("I'm a Kitten");
     50    }
     51}
     52}}}