阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。[说明] 编写一个学生类Student,要求:(1) 学生类Student 属性有:id: long 型,代表学号name: String类对象,代表姓名age: int 型,代表年龄sex: boolen 型,代表性别(其中:true 表示男,false 表示女)phone: String 类对象,代表联系电话(2) 学生类Student 的方法有:Student (long i,String n,int a,boolean s,String p):有参构造函数,形参表中的参数分别初始化学号、姓名、年龄、性别和联系电话。int getAge ():获取年龄作为方法的返回值。boolean getSex ():获取性别作为方法的返回值。String getPhone ():获取联系电话作为方法的返回值。public String to String ():以姓名:性别:学号:联系电话的形式作为方法的返import java. applet. Applet;import java. awt.* ;public class Student extends Applet {long id;String name, phone;int age;boolean sex;Student(long i, String n, int a, boolean s, String p){id=i;name = n;age = a;sex= s;phone = p;{public void paint( Graphics g){Student x= new Student (5000," xiaoliu" , 89, true, " 8989898" );(1);(2)g. drawstring( x. getPhone( ), 140,140);}int getAge( ){ return age; }boolean getsex ( ){ return sex; }String getPhone( ){ return phone; }String ToString( ){(3)}}
阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。
[说明] 编写一个学生类Student,要求:
(1) 学生类Student 属性有:
id: long 型,代表学号
name: String类对象,代表姓名
age: int 型,代表年龄
sex: boolen 型,代表性别(其中:true 表示男,false 表示女)
phone: String 类对象,代表联系电话
(2) 学生类Student 的方法有:
Student (long i,String n,int a,boolean s,String p)
:有参构造函数,形参表中的参数分别初始化学号、姓名、
年龄、性别和联系电话。
int getAge ():获取年龄作为方法的返回值。
boolean getSex ():获取性别作为方法的返回值。
String getPhone ():获取联系电话作为方法的返回值。
public String to String ():以姓名:性别:学号:联系电话的形式作为方法的返
import java. applet. Applet;
import java. awt.* ;
public class Student extends Applet {
long id;
String name, phone;
int age;
boolean sex;
Student(long i, String n, int a, boolean s, String p)
{
id=i;
name = n;
age = a;
sex= s;
phone = p;
{
public void paint( Graphics g)
{
Student x= new Student (5000," xiaoliu" , 89, true, " 8989898" );
(1);
(2)
g. drawstring( x. getPhone( ), 140,140);
}
int getAge( )
{ return age; }
boolean getsex ( )
{ return sex; }
String getPhone( )
{ return phone; }
String ToString( )
{
(3)
}
}