1 Abstract classa{2 PrivateString name;3 PublicA (String name) {4 This. Name =name;5 }6 PublicString GetName () {7 return This. Name;8 }9 Public Abstract voidFun ();Ten } One classBextendsa{ A PublicB (String name) { - Super(name); - } the Public voidFun () { -System.out.println (Super. GetName ()); - } - } + Public classL { - Public Static voidMain (string[] args) { + //TODO auto-generated Method Stub Ab b =NewBNULL); at B.fun (); - } - } - Importjava.sql.Date; - -@SuppressWarnings ("Unused") in Public Abstract classY { - PrivateString name; to PrivateString Class; + PrivateString date; - the PublicString GetName () { * return This. Name; $ }Panax Notoginseng Public voidsetName (String name) { - This. Name =name; the } + PublicString getclass () { A return This. Class; the } + Public voidSetClass (String Class) { - This. Class =Class; $ } $ PublicString getDate () { - return This. Date; - } the Public voidsetDate (String date) { - This. Date =date;Wuyi } the PublicY (String name,string class,string date) { - This. Name =name; Wu This. Class =Class; - This. Date =date; About } $ PublicY () { - Super(); - } - A @Override + PublicString toString () { the return"Student [name=" + name + "]"; - } $ Public AbstractString speak (); the the } the Importjava.sql.Date; the@SuppressWarnings ("Unused") - Public classHextendsy{ in PrivateString matter; the PublicH (String name,string class,string date,string matter) { the Super(name,class,date); About This. Setmatter (matter); the } the @Override the PublicString speak () { + return"My Name" +Super. GetName () + "this year" +Super. GetClass () + "height" +Super. GetDate () + "weight" + This. matter; - } the PublicString Getmatter () {Bayi returnmatter; the } the Public voidSetmatter (String matter) { - This. Matter =matter; - } the the } the Public classK { the - Public Static voidMain (string[] args) { the //TODO auto-generated Method Stub theY stu =NewH ("Lo Yuanhao,", "19 years old,", "173cm,", "52KG. "); the print (Stu.speak ());94 } the the Private Static voidprint (String speak) { the System.out.println (speak);98 About } - 101}
Java Practice---14