Static internal abstract classes can be inherited.
public class Testfather {
public static void Main (string[] args) {
Person.talk2 a = new Newtalk ();
A.get ();
Person Person1 = new Student ("Alice", 20, "female");
System.out.println (Person1.talk ());
/* Person Person2 = new person (); *///abstract class cannot be called
}
}
Abstract class Person {
String name;
int age;
String sex;
Public person (string name, int age, string sex)//wait and try to call the constructor method
{
THIS.name = name;
This.age = age;
This.sex = sex;
}
Public abstract String talk (); Declares an abstract method that can not write its method content
Static abstract class TALK2//internal abstract classes, statically methods can be inherited
{
public abstract void get ();
}
}
Class Newtalk extends Person.talk2 {//Verify the inheritance of internal static classes (equivalent to a separate abstract class)
public void get () {
SYSTEM.OUT.PRINTLN ("Character information:");
}
}
Class Student extends Person {
Public student (string name, Int. age, String sex) {
Super (name, age, Sex); Inheriting parent class construction methods
}
Public String Talk () {
Return "Name:" + name + "Age:" + Ages + "Gender:" + sex;
}
}
java--Abstract class instance (contains static internal abstract class)