2021-09-22
- http://www.plantuml.com/plantuml/png/SoWkIImgAStDuKfCAYufIamkKO02nxpCtCGShioyajIYjCJaLAYmStvEVX66g7jgNafg4HT4Zu9DZQukPq1cEWhV9H-LxvnOmWLK0zGCLvzUoUMI3nS16mpa0qM1Qb54lJDBIbBpkC1k0GdhwO65GKP2N88gvW0K0teH0000
@startuml abstract Animal interface Color interface Gender Animal <|-- Pig Animal <|-- Dog Animal <|-- Cat Pig <|-- Piggy Dog <|-- Doggy Cat <|-- Kitten Color <|.. Cat Gender <|.. Cat @enduml
public class HelloWorld{ public static void main(String []args){ System.out.println("Hello World"); Animal a = new Cat(); Animal b = new Kitten(); a.who_am_i(); b.who_am_i(); } } abstract class Animal { abstract void who_am_i(); } class Cat extends Animal { void who_am_i() { System.out.println("I'm a Cat"); } } class Kitten extends Cat { void who_am_i() { System.out.println("I'm a Kitten"); } }
using System.IO; using System; class Program { static void Main() { Console.WriteLine("Hello, World!"); Animal animal = new Cat(); animal.who_am_i(); animal = new Kitten(); animal.who_am_i(); } } abstract class Animal { public abstract void who_am_i(); } class Cat:Animal { public override void who_am_i() { Console.WriteLine("I'm a Cat"); } } class Kitten:Cat { public override void who_am_i() { Console.WriteLine("I'm a Kitten"); } }
Last modified 3 years ago
Last modified on Oct 10, 2021, 10:38:25 AM
Attachments (1)
-
OOP_Concepts.png
(15.4 KB) -
added by jazz 3 years ago.
Object Oriented Programming Concepts
Download all attachments as: .zip