单选

下列说法正确的是(  )。

  • A.类FileInputStream和FileOutputStream用来进行文 件I/O处理,由它们所提供的方法可以打开本地主机上的文件,并进行顺序的读/写
  • B.通过类File的实例或者一个表示文件名称的字符串可以生成文件输入/输出流,在流对象生成的同时,文件被 打开,但还不能进行文件读/写
  • C.对于InputStream和OutputStream来说,它们的实例都是是非顺序访问流,即只能进行顺序的读/写
  • D.当从标准输入流读取数据时,从键盘输入的数据直接输入到程序中
参考答案
您可能感兴趣的试题

本题中,鼠标在窗口中单击一下,就在单击的位置生成一个小矩形,如果在小矩形上双击鼠标左键,则删除小矩形。

import java.awt.*;

import java.awt.event.*;

import javax swing.*;

class MousePanel extends JPanel extends MouseMo-

tionListener

{public MousePanel

{addMouseListener(new MouseAdapter

{public void mousePressed(MouseEvent evt)

{int X=evt.getX;

int Y=evt.getY;

current=find(x,y);

if(current<0)

add(x,y);

}

public void mouseClicked(MouseEvent evt)

{int X=evt.getX;

int Y=evt.getY;

if(evt.getClickCount>=2)

{remove(current);

}

});

addMouseMotionListener(this);

}

public void paintComponent(Graphics g)

{super.paintComponent

for(int i=0;i

draw(g,i);

}

public int find(int X,int y)

(for(int i=0;i

if(squares[i].x-SQUARELENGTH/2<=

x

X<=squares[i].x+SQuARELENGTH/2

squares[i].Y-SQUARELENGTH/2<

=Y

y<=squares[i].Y+SQUARELENGTH

/2)

return i ;

return-1 ;

}

public void draw(Graphics g,int i)

{g.drawRect(squares[i].X-SQUARE-

LENGTH/2。

squares[i].Y-SQUARELENGTH/2,

SQUARELENGTH,

SQUARELENGTH);

}

public void add(int X,int Y)

{if(nsquares

{squares[nsquares]=new Point(x,y);

current=nsquares ;

nsquares++;

repaint;

}

}

public void remove(int n)

{if(n<0 ‖ n>=nsquares)return;

Nsquares- -;

squares[n]=squares[nsquares];

if(current= =n)current= -l;

repaint;

}

public void mouseMoved(MouseEvent evt)

{}

public void mouseDragged(MouseEvent evt)

{}

private static final int SQUARELENGTH=10:

private static final int MAXNSQUARES=100;

private Point[]squares=new Point[MAX-

NSQUARES];

private int nsquares=0;

private int current=-l;

}

class MouseFrame. extends JFramc

{public MouseFrame

{setTitle("java3");

setSize(300,200);

addWindowListener(new WindowAdapter

{public void windowClosing(WindowEvent e)

{System.exit(0);

}

});

Container contentPane=getContentPane;

contentPane.add(MousePanel)

}

public class java3

{public static void main(String[]args)

{JFrame. frame=new MouseFrame;

frame.show;

}

}

本题中,用表格表现某个月的月历,其中标题是从Sunday到Saturday,表格中的各项是可以修改的。

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.table.*; 

public class java2

(

public static void main(String[]args)

{

try{

UIManager.setLookAndFeel(UIManager.getSys-

temLookAndFeelClassName):

}

catch(Exception e)

JFrame. frame=new CalendarTableFrame;

frame.setDefaultCloseOperation(JFrame.EXIT_

oN CLOSE);

frame.show;

}

}

clasgCalendarTableFrame. extends JFrame

{

private static final int WIDTH=500;

private static final int HEIGHT=150:

private        cells=

{

{null,null,null,new Integer(1),new Integer

(2),new Integer(3),new Integer(4)),

{new Integer(5),new Integer(6),new Integer

(7).new Integer(8),new Integer(9),new Integer

(10),new Integer(11)),

{new Integer(12),new Integer(13),new Integer

(14),new Integer(15),new Integer(16),new Integer

(17),new Integer(18)),

{new Integer(19),new Integer(20),new Integer

(21),new Integer(22),new Integer(23),new Integer

(24),new Integer(25)),

{new Integer(26),new Integer(27),new Integer

(28),new Integer(29),new Integer(30),new Integer

(31),null}

};

private String[]columnNames={

"Sunday","Monday","Tuesday","Wednesday",

"Thursday","Friday","Saturday"

};

public CalendarTableFrame{

setTitle("java2");

setSize(WIDTH,HEIGHT);

JTable table=new         ;

getContentPane.add(new JScrollPane(table),

BorderLayout.CENTER);

}

下列说法正确的是(  )。

  • A.类FileInputStream和FileOutputStream用来进行文 件I/O处理,由它们所提供的方法可以打开本地主机上的文件,并进行顺序的读/写
  • B.通过类File的实例或者一个表示文件名称的字符串可以生成文件输入/输出流,在流对象生成的同时,文件被 打开,但还不能进行文件读/写
  • C.对于InputStream和OutputStream来说,它们的实例都是是非顺序访问流,即只能进行顺序的读/写
  • D.当从标准输入流读取数据时,从键盘输入的数据直接输入到程序中

当检索一个压缩文件时,首先要建立压缩文件输入流对象,该对象(  )。

  • A.以选中的压缩文件为参数
  • B.以FileInputStream对象为参数
  • C.以InputStreamReader对象为参数
  • D.以BufferedReader对象为参数

下列变量的定义中,错误的是(  )。 

  • A.int X=3; 
  • B.float f;d;
  • C.String s="Hell0";
  • D.boolean b=true;
¥

订单号:

遇到问题请联系在线客服

订单号:

遇到问题请联系在线客服