问题 多项选择题

[说明]
以下JAVA程序设计了类CSet,使用同一个名称(set)的method来传入数据。仔细阅读[代码6-1)、[代码6-2]和[代码6-3]和相关注释,将程序补充完整。
[代码6-1]
import java.io.*;
class CSet

private int width;
private int height;
(1)
public void set(String color)

col=color; //

(a)可输入长方形的颜色

public void set (iht w, int h)

width=w; //
(b)可输入长方形的宽和高
height=h;

public void set (String color, int w, int h)

col=color; //
(c)可输入长方形的颜色、宽和高
width=w;
height=h;

public void show ( )

System.out.println ("n\长方形的颜色为: "+col);
System.out.println ("n\长方形宽为: "+width+" 长方形高为: "+height");


[代码6-2]
public class hw8_3

public static void main (String args[]) throws IOException

intw, h; //声明宽、长变量,并给予赋值
String color, k;
CSet rect1;
rect1=new CSet ( );
System.out.print ("\n请输入颜色:: ");
color=input ( );
System.out.print ("请输入宽度:: ");
k=input ( );
w=Integer.parseInt (k);
System.out.print ("请输入高度:: ");
k=input( );
h=Integer.parseInt (k);
(2) //设置长方形的颜色
(3) //设置长方形的宽、高
rectl.show ( );
(4) //设置长方形的颜色和宽、高
rectl.show ( );

[代码6-3]
public static String input( ) throws IOException//输入函数

String str;
BufferedReader buf;
(5)
str=buf.readLine ( )
return str;


答案

参考答案:(A)pfivate String col;
(B)rectl.set (color);
(C)rectl.set (w,h);
(D)rectl.set (color,w,h);
(E)buf=new BufferedReader (new InputStreamReader (System.in));

解析: 程序中定义了类CSet,使用同一个名称(set)的method来传入数据。本题需要考生仔细阅读代码,因为代码中有的变量是在后来出现的,而前边又没有定义,那么肯定需要在空缺处定义。另外,有些语句逻辑上没有先后关系,但填空时需要按顺序填写,因为有注释区分。本题并不难,但代码长。设计此题的目的希望考生又较强的阅读代码能力,因为只有读完了全部代码,才可以明白前面的空缺应该填写什么。

单项选择题
单项选择题

Time spent in a bookshop can be most enjoyable, whether you are a book-lover or merely there to buy a book as a present. You may even have entered the shop just to find shelter from a sudden shower. But the desire to pick up a book with an attractive dust-jacket is irresistible. You soon become absorbed in some book or other, and usually it is only much later that you realize that you have spent far too much time there.

This opportunity to escape the realities of everyday life is, I think, the main attraction of a bookshop. There are not many places where it is possible to do this. A music shop is very much like a bookshop. You can wander round such places to your heart’s content. If it is a good shop, no assistant will approach you with the inevitable greeting: "Can I help you, sir" You needn’t buy anything you don’t want. In a bookshop an assistant should remain in the background until you have finished browsing. Then, and only then, are his services necessary.

You have to be careful not to be attracted by the variety of books in a bookshop. It is very easy to enter the shop looking for a book on, say, ancient coins and to come out carrying a copy of the latest best-selling novel and perhaps a book about brass-rubbing -- something which had only vaguely interested you up till then. This volume on the subject, however, happened to be so well illustrated and the part of the text you read proved so interesting that you just had to buy it. This sort of thing can be very dangerous. Booksellers must be both long suffering and indulgent.

There is a story which wei1 illustrates this. A medical student had to read a textbook which was far too expensive for him to buy. He couldn’t obtain it from the library and the only copy he could find was in his bookshop. Every afternoon, therefore, he would go along to the shop and read a little of the book at a time. One day, however, he was dismayed to find the book missing from its usual place and about to leave when he noticed the owner of the shop beckoning to him. Expecting to be reproached, he went toward him. To his surprise, the owner pointed to the book, which was tucked away in a corner. "I put it there in case anyone was tempted to buy it," he said, and left the delighted student to continue his reading.

It can be learned from the text that an assistant should offer you help()

A. as soon as you have entered the shop

B. just before you finish browsing

C. only when you have finished reading

D. when he leads you to a particular section