Java Course

class Car

{

protected int wheels;

Car()

{

System.out.println("The car is created");

}

public int getWheels()

{

return wheels;

}

}

 

class Model extends Car

{

Model()

{

wheels = 4;

}

}

class MyClass

{

public static void main (String [] args)

{

Model a = new Model();

System.out.println("with " + a.getWheels() + " wheels");

}

}

More on Inheritance

public class Fauna

{

Fauna()

{

System.out.println("Fauna is alive");

}

}

public class Bird extends Fauna

{

Bird()

{

System.out.println("Bird hatching from egg");

}

}

class Program

{ vpublic static void main(String [] args)

{

Bird hawk = new Bird();

} }



Dodaj komentarz






Dodaj

© 2013-2024 PRV.pl
Strona została stworzona kreatorem stron w serwisie PRV.pl