Home
Random
Recent changes
Special pages
Community portal
Preferences
About Vestibule Technical Wiki
Disclaimers
Vestibule Technical Wiki
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Cat and Dog examples
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
A Cat and Dog example is an artificial example often inspired by real life objects used to teach programming, particularly Software Architecture, and particularly [[Object Oriented Programming]] <pre> // Parent class class Animal{ void sound(){ System.out.println("Animal makes a sound"); } } // Child class class Dog extends Animal{ @Override void sound(){ System.out.println("Dog barks"); } } // Child class class Cat extends Animal{ @Override void sound(){ System.out.println("Cat meows"); } } // Driver class public class Driver { public static void main(String[] args){ Animal a = new Dog(); a.sound(); a = new Cat(); a.sound(); } } </pre> Other common examples include * Various kinds of shapes * Cars and Vehicles Of course, while these appear to be "real life examples", they are completely silly and nothing like what we actually do in programming. And even in these examples, slight examination will lead one to discover members of the hierarchy such as <code>LandVehicleWithTwoWeels</code>, <code>ShapeWithCorners</code> and <code>AnimalsWithFurAndWarmBloodButWhichDoNotGiveLiveBirth</code>. Complex inheritance hierarchies do not survive the complexities of real life.
Summary:
Please note that all contributions to Vestibule Technical Wiki are considered to be released under the Creative Commons Zero (Public Domain) (see
Vestibule Technical Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)