inheritance java class super code example
Example 1: inheritance in java
// super class
class Animal
{
void eat()
{
System.out.println("Animal is eating.");
}
}
// subclass
class Lion extends Animal
{
public static void main(String[] args)
{
Lion obj = new Lion();
obj.eat();
}
}
Example 2: how to create a subclass in java
class Super {
Number aNumber;
}
class Sub extends Super {
Float aNumber;
}