Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Output students' names, student numbers, gender, grades and other parameters with polymorphic methods in Java.
Output students' names, student numbers, gender, grades and other parameters with polymorphic methods in Java.
Abstract? Class? Student? {

Protected? int? studentNum

Protected? String? Name;

Protected? String? Sex;

Protected? Double? Ji Cheng;

Public? Student ()? {

}

Public? Student (int? Number of students? String? Name,? String? Sex? Double? Ji Cheng)? {

this.studentNum? =? studentNum

This name? =? Name;

This. Sex? =? Sex;

This. Chengji? =? Ji Cheng;

}

Abstract? Invalid? getPrint();

}

//? Output students' names, student numbers, gender, grades and other parameters with polymorphic methods in Java.

Public? Class? StudentDemo? Extension? Student? {

Public? StudentDemo()? {}

Public? StudentDemo(int? Number of students? String? Name,? String? Sex? Double? Ji Cheng)? {

Super (studentNum, name,? Sex? Ji Cheng);

}

Invalid? getPrint()? {

System.out.println ("student number:"? +? super . student num);

System.out.println ("Name:"? +? super . name);

System.out.println ("gender:"? +? super . sex);

System.out.println ("grade:"? +? super . chengji);

}

Public? Static electricity Invalid? main(String[]? args)? {

//polymorphic instantiation

Student? s 1? =? New? StudentDemo( 1, "Xiao Ming", "Male", 98.95);

//Output student information

s 1 . get print();

system . out . println();

//Convert to subclass type, that is, convert down.

Student? Student? =? (student) s1;

student . get print(); //output

}

}