问题 填空题

补全短文。根据短文内容,从短文后的A-F选择中,选出5个适当的选项补全短文,并将代表句子的字母填写在答题卡相应的题号位置上。(共5小题,每小题1分;计5分)

Happiness is for everyone. You don't need to care  about those who have beautiful houses with large gardens and swimming pools or those who have nice cars and lots of money and so on. Why?

Because those who have big houses may often feel lonely and those who have cars may want to walk on the country roads at their free time.

__小题1:___________When you are in trouble at school, your friends will help you; when you study hard at your lessons, your parents are always taking good care of your life and your health; when you get success, _小题2:___________. When you do something wrong, people around you will help you to correct. And when you do something good to others, you will feel happy, too. All these are your happiness. If you notice them, you can see that happiness is always around you.

Happiness is not the same as money. _小题3:____________When you are poor, you can also say you

are very happy, because you have something else that can't be bought with money. When you meet with difficulties, you can say loudly you are very happy, because you have more chances to challenge yourself._小题4:____________ As the saying goes, Life is like a revolving (旋转的) door. When it closes, it also opens. _小题5:___________

答案

小题1:B

小题2:D

小题3:E

小题4:C

小题5:A

题目分析:这篇短文主要介绍了每个人都有自己的幸福。如果你抓住每一个机会,你就可以是一个快乐和幸运的人。

小题1:根据后文描述你在学校遇到了麻烦,你的朋友会帮助你, ……,可知,故填B

小题2:根据上文你获得了成功,你的朋友会祝贺你,故填D

小题3:根据后文When you are poor, you can also say you are very happy, because you have something else that can't be bought with money。。。,可知幸福是自己内心的一种感受,故填 E

小题4:根据上文的描述,当处于不好的境遇中你也能说自己是幸福的,故选C

小题5:根据上文,如果你抓住每一个机会,你可以是一个快乐和幸运的人,故选A,

多项选择题
问答题

1.SMTP是发送E-mail的协议,常用以下5条命令发送E-mail:
HELO,与SMTP服务器握手,传送本机域名;
MAILFROM:,传送发信者的信箱名称;
RCPTTO:,传送接收者的信箱名称;
DATA,发送邮件数据(包括信头和信体);
QUIT,退出与SMTP服务器的连接。
2.试题中直接利用的类及方法如下:
(1)类ServerSocket(int port)实现TCP服务器接口(socket),它提供两种构造函数,用它们来指定服务器插口所用的端口,并监听到达的连接请求。类中的主要方法有:
accept( ):启动服务器插口监听并等待,直到建立连接为止,一旦建立连接就返回Socket类的一个对象。
getInetAddress( ):返回插口所连接的主机地址。
getLocaIPort( ):返回在服务器插口上建立了连接的端口。
close( ):关闭服务器插口。
(2)类InetAddress包装了Internet地址。类中的主要方法有:
getLocaIHost( ):返回一个代表本机Internet地址的InetAddress对象。
getaddress( ):获得数字表示的IP地址。
getHostName( ):获得域名。
(3)类Socket实现基于连接的客户插口。类中的主要方法有getInetAddress( ):返回一个与插口连接的客户机的Internet地址,其类型为InetAd-dress。getlnputStream( ):用来访问与插口相关的输入流。getOutputStream( ):用来访问与插口机关的输出琉。close( ):关闭插口。
(4)readLine( )是输入流类的一个方法,用于服务器或客户从对方读入一行输入流信息。
(5)用户白定义类NVTInputStream(InputStream inStream, OutputStream outStream)实现了网络虚拟终端输入接口。
(6)用户自定义类NVTOutputStream(OutputStream outStream)实现了网络虚拟终端输接口。
3.下面是用Java语言实现的一个简单SMTP服务器程序的部分代码。
[程序代码]
import java.net. *:
import java.io. *;
import jdg. yan. NVTlnputStream; //用户自定义类包
import jdg. yan. NVTOutputStream; //用户自定义类包
public class SMTPServer App

public static void main(String args[])

SMTPServer server=new SMTPServer( );
server. run( );


class SMTPServer

static final int HELO=1;
static final int MAIL=2;
static final int RCPT=3;
static final int DATA=4;
static final int END_DATA=5;
static final int OUIT=6;
static final int FINISHED=9;
NVTOutputStream out;
NVTInputStream in;
String hostName;
public SMTPServer( )

super( );

public void run( )
try
ServerSOcket server= (1) ;//在1145号端口建立下CP服务器插口
int localPort=server. getLocalPort( );//监听连接端口
hostNama= (2) ;//获取本地主机域名
SVstem. out. prfntln("listening on port"+locaIPort+".");
boolean finished=false;
do
Socket client= (3) ;//监听等待,直到建立连接,返回对象client
Stnng destName= (4) ;//获得所连接的客户主机IP地址的域名
int destPort=client. getPort( );//所连接的客户主机端口号
System. out pnntln("Accepted connection to"+destNama+"on port"+destPort+"."
//控制台显示连接
out=new NVT0utputStream(client. get OutputStream( ));
In=new NVTInputStream( (5) );//建立与连接关联的输入流
(6) ;//接收邮件
(7) ;//关闭连接对象
while(! finished);
catch(UnknownHostException ex)
SVstem.out.printtn("UnknownHostException occurred.");//出错处理
cath(lOException ex)
System. out. println("lOException occurred.");


vold getMail( ) //实现SMTP的子集,从客户接收邮件
out. println("Server220"+hostName+"Ready!");
int state=HELO; //设置状态为HELO,state保存与客户通信的状态
do //接收并处理从邮件客户接收到的命令
String line="";
out. println("Server 250 HELO, OK!");
try
line= (8) ;//从虚拟终端读取一行
if(line==null)state=FINISHED;
catch(IOException ex)
System. out. prmntln("Server IOExceptlon occurred.");
System.exit(1);

switch(state)
case HELO:
if( (9) )//若该行信息为传送本机域名

out. println("Server 250 Hello");
System. out. println(line);
state=MAIL;
else
out. println("Server 500 ERROR");
System. out. println("Server"+line);

state=FINISHED;
break’
case MAIL: //省略代码
case RCPT: //省略代码
case DATA:
if( (10) )//若该行信息为发送邮件数据

out. println("354 mail input; end with.");
System. out. println(line);
state=END_DATA;
else
out. println("500 ERROR");
System. out. println(line);

break;
case END_DATA;//代码省略
case QUIT://代码省略

while(state!=FtNISHED);

//判断客户收到的命令是否与指定的命令字符串相匹配
boolean commandls(String s, String line)
int n=s. length( );
if(s.equalslgnoreCase(line. substring(0.n)))return true;
return false;