Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Angestellter{
- public int alter ;
- public String name ;
- public Angestellter( String name , int alter){
- this.name = name ;
- this.alter = alter ;
- }
- public String toString() {
- return name + " ( " +alter+ " ) " ;
- }
- public static void main( String[] args){
- String s , abt ;
- Angestellter a = new Angestellter("Schmidt",30);
- Chef b = new Chef( "Meier" , 37," Buchhaltung " ) ;
- s = a.name;
- a = b;
- abt = ((Chef) a).abteilung;
- System.out.println(a.toString());
- System.out.println(b.toString());
- }
- }
- class Chef extends Angestellter{
- public String abteilung ;
- public Chef( String name , int alter, String abteilung){
- super( name , alter);
- this.abteilung = abteilung;
- }
- public String toString(){
- String s = super . toString ( ) ;
- return s + " leitet " + abteilung ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement