阅读以下说明和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)

}

}


相关考题:

阅读以下说明和Java码,将应填入(n)处的字名写在对应栏内。[说明] 编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。import java. io. * ;public class abc{public static void main(String args [ ] ){ int i, n = 10 , max = 0 , min = 0 , temp = 0;try {BufferedReader br = new BufferedReader(new InputStreamReader( System. in) );(1));} catch ( IOException e ) { } ;for(i = 2 ;i <= n; i ++ ) {try {BufferedReader br = new BufferedReader(new InputStreamReader (System. in) );temp = Integer. parselnt(br. readLine( ) );if ( temp > max ) (2)if (temp < min) (3)} catch ( IOExeeption e ) { } ;System. out. println( "max =" + max + "\nmin =" + min);}}

阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。[说明]设学生某次考试的成绩按学号顺序逐行存放于某文件中,文件以单行句点“.”为结束符。下面的流程图读取该文件,统计出全部成绩中的最高分max和最低分min。

阅读以下说明和c++码,将应填入(n)处的字名写在的对应栏内。[说明] 以下函数完成求表达式的值,请填空使之完成此功能。float sum ( float x ){ float s=0.0;int sign = 1;(1);for(inti=1;(2); i+ +){t=t*x;s=s+(3);sign = - sign;(4);}

阅读下列说明和流程图,将应填入(n)处的语句写在对应栏内。【说明】下列流程图用泰勒(Taylor)展开式y=ex=1+x+x2/2!+x3/3!+…+xn/n!+…计算并打印ex的近似值,其中用ε(>0)表示误差要求。【流程图】

阅读以下说明和Java以及HTML代码,将应填入(n)处的字句写在对应栏内。[说明]编写一个Applet程序,接受HTML文件传递的整数参数,根据该参数指定Applet中文本框的长度。编写对应的HTML文件运行这个Applet。[Java 代码]import java. applet.*;import java. awt.*;public class chuangdics extends (1){TextField tf=new TextField ();int tfLength=0;public void init(){try{tfLength=Integer. parseInt( (2) ("length"));tf. setColumns (tfLength);add (tf);}catch (NumberFormatException nfe){tf. (3) ("HTML 文件传人的参数格式错误。");add(tf);}}}[HTML 代码]<html><head><title>(4)</title></head><body><hr><applet code=chuangdics width=700 height=150><param name=length value=20>(5)<hr></body></htmI>

阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。[说明]以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。[JAVA代码]//定义自己的异常类class CCircleException extends Exception{}// 定义类 CCircleclass CCircle{private double radius;public void setRadius ( double r ) (1){if ( r<0 ) {(2)}else(3)}Public void show ( ) {System. out. println ( "area="+3.14*radius*radius );}}public class ciusample{public static void main ( String args[] ){CCircle cir=new CCircle( );(4) {cir. setRadius ( -2.0 )}(5){System. out. println ( e+" throwed" ) ;}cir. show( ) ;}}

试题三(共 15 分)阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。

阅读下列说明和Java代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】 某文件管理系统中定义了类OfficeDoc和DocExplorer,当类OfficeDoc发生变化时,类DocExplorer的所有对象都要更新其自身的状态,现采用观察者(Observer)设计模式来实现该需求,所设计的类图如图6-1所示。

阅读下列说明和?C++代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】阅读下列说明和?Java代码,将应填入?(n)?处的字句写在答题纸的对应栏内。【说明】某快餐厅主要制作并出售儿童套餐,一般包括主餐(各类比萨)、饮料和玩具,其餐品种类可能不同,但其制作过程相同。前台服务员?(Waiter)?调度厨师制作套餐。现采用生成器?(Builder)?模式实现制作过程,得到如图?6-1?所示的类图。