计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
Java语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题本程序使用下拉菜单来控制字体,窗口中有一个标签和一个下拉菜单,当选中下拉菜单中的任一项字体时,标签上字符串的字体就随之改变,如图所示。importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;classComboBexFrameextendsJFrame______{publicComboBoxFrame(){setTitle("exam_13");setSize(300,200);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});style=newJComboBox();style.setEditable(true);style.addItem("Serif");style.addItem("SansSerif");style.addItem("Monospaced");style.addItem("Dialog");style.addItem("DialogInput");style.addActionListener(this);JPanelp=newJPanel();p.add(style);getContentPane().add(p,"South");panel=newComboBoxTestPanel();getContentPane().add(panel,"Center");}publicvoidactionPerformed(ActionEventevt){JComboBoxsource=(JComboBox)______;Stringitem=(String)source.getSelectedItem();panel.setStyle(item);}privateComboBoxTestPanelpanel;privateJComboBoxstyle;}classComboBoxTestPanelextendsJPanel{publicComboBoxTestPanel(){setStyle("Serif");}publicvoidsetStyle(Strings){setFont(newFont(s,Font.PLAIN,12));repaint();}publicvoidpaintComponent(Graphicsg){super.paintComponent(g);g.drawString("WelcometoChina!",0,50);}}publicclassexam_13{publicstaticvoidmain(String[]args){JFrameframe=newComboBoxFrame();frame.show();}}
进入题库练习
问答题下面是一个Applet程序,其功能是通过一个按钮控制一个窗口的创建,显示与隐藏,并且以按钮文字作为提示,可以随着窗口的状态改变,即如果窗口出现,则按钮文字为“HidemyFrm”,提示用户点击按钮,则隐藏窗口,反之亦然。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:importjava.awt.*;importjava.applet.*;/*<appletcode="ex5_3.class"width=800height=400></applet>*/publicclassex5_3extendsApplet{privateFramerrm;privateButtonshowBtn;publicvoidinit(){showBtn=newButton("ShowFrame");add(showBtn);}publicbooleanaction(Evente,Objecto){if(e.target==showBtn){if({{U}}frm==null{{/U}}){{{U}}frm.show{{/U}}();frm.dispose();frm=null;showBtn.setLabel("ShowmyFrm");}else{frm=newFrame("myFrm");frm.resize(200,150);frm.setBackground(Color.gray);{{U}}frm.hide{{/U}}();showBtn.setLabel("HidemyFrm");}}returntrue;}}{{B}}ex5_3.htm1{{/B}}<HTML><HEAD><TITLE>ex5_3</TITLE></HEAD><BODY><appletcode="ex5_3.class"width=800height=400></applet></BODY></HTML>
进入题库练习
问答题下面程序的目的是在屏幕上显示当前目录下的文件信息。文件信息通过表格JTable的实例显示。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 import java.awt.*; import javax.swing.*; import java.util. Date; import javax.swing.table.*; import java.applet.*; import java.io.*; public class Example3_10 {{U}}extends JApplet, JFrame{{/U}} { public void init() { FileModel fm = new FileModel(); JTable jt = new {{U}}JTable(){{/U}}; jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jt.setColumnSelectionAllowed(true); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); } public static void main(String args[]) { Example3_10 ft = new Example3_10(); ft.init(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT ON CLOSE); f.getContentPane() .add(ft.getContentPane()); f.setSize (300, 400); f.show(); } } class FileModel extends AbstractTableModel { String[] columnName = new String[] { "文件名", "大小", "最后修改时间" } Object[] [] data; public FileModel() { this("."); } public FileModel(String dir) { File file = new File(dir); String files[] = file.list(); data = new Object [files.length] [columnName.length]; for (int i=0; i < files.length; i++) { File tmp = new File (files[i]); data[i] [0] = tmp.getName(); data[i] [1] = new Long(tmp.length()); data[i] [2] = new Date(tmp.lastModified() ); } } public int {{U}}getColumnNumber{{/U}}() { return columnName.length; } public int getRowCount() { return data. length; } public String getColumnName(int col) { return columnName[col]; } public Object getValueAt(int row, int col) { return data[row] [col]; } public Class getColumnClass(int c) { return getValueAt (0, c) .getClass(); } }
进入题库练习
问答题本程序的功能是监听对表格的选择。窗口中有一个表格、三个复选框和两个文字标签,复选框指定的是当前进行的选取是单元还是行或者是列,文字标签显示当前所选的行或列数,如图所示。importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjavax.swing.event.*;importjavax.swing.table.*;publicclassexam_43extendsJFrame{publicexam_43(){super("exam_43");setSize(450,350);setDefaultCloseOperation(EXIT_ON_CLOSE);TableModeltm=newAbstractTableModel(){publicintgetRowCount(){return10;}publicintgetColumnCount(){return10;}publicObjectgetValueAt(intr,intc){return""+(r+1)*(c+1);}};finalJTablejt=newJTable(tm);JScrollPanejsp=newJScrollPane(jt);getContentPane().add(jsp,BorderLayout.CENTER);JPanelcontrolPanel,buttonPanel,columnPanel,rowPanel;JPanelbuttonPanel=newJPanel();finalJCheckBoxcellBox,columnBox,rowBox;cellBox=newJCheckBox("单元",jt.getCellSelectionEnabled());columnBox=newJCheckBox("列",jt.getColumnSelectionAllowed());rowBox=newJCheckBox("行",jt.getRowSelectionAllowed());cellBox.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventae){jt.setCellSelectionEnabled(cellBox.isSelected());columnBox.setSelected(jt.getColumnSelectionAllowed());rowBox.setSelected(jt.getRowSelectionAllowed());}});columnBox.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventae){jt.setColumnSelectionAllowed(columnBox.isSelected());cellBox.setSelected(jt.getCellSelectionEnabled());}});rowBox.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventae){jt.setRowSelectionAllowed(rowBox.isSelected());cellBox.setSelected(jt.getCellSelectionEnabled());}});buttonPanel.add(newJLabel("允许的选择:"));buttonPanel.add(cellBox);buttonPanel.add(columnBox);buttonPanel.add(rowBox);columnPanel=newJPanel();ListSelectionModelcsm=jt.getColumnModel().getSelectionModel();JLabelcolumnCounter=newJLabel("(这里将显示列的选择)");csm.addListSelectionListener(newSelectionDebugger(columnCeunter,csm));columnPanel.add(newJLabel("选中的列:"));columnPanel.add(columnCounter);rowPanel=newJPanel();ListSelectionModelrsm=jt.getSelectionModel();JLabelrowCounter=newJLabel("(这里将显示行的选择)");rsm.addListSelectionListener(newSelectionDebugger(rowCounter,rsm));rowPanel.add(newJLabel("选中的行:"));rowPanel.add(rowCounter);controlPanel=newJPanel(newGridLayout(0,1));controlPanel.add(buttonPanel);controlPanel.add(columnPanel);controlPanel.add(rowPanel);getContentPane().add(controlPanel,BerderLayout.SOUTH);}publicstaticvoidmain(Stringargs[]){exam_43se=newexam_43();se.setVisible(true);}publicclassSelectionDebuggerimplementsSelectionListener{JLabeldebugger;ListSelectionModelmodel;publicSelectionDebugger(JLabeltarget,ListSelectionModellsm){debugger=target;model=lsm;}publicvoidvalueChanged(ListSelectionEventlse){if(!ise.getValueIsAdjusting()){StringBufferbuf=newStringBuffer();int[]selection=getSelectedIndices(model.getMinSelectionIndex(),model.getMaxSelectionIndex());if(selection.length==0){buf.append("none");}else{for(inti=0;i<selection.length-1;i++){buf.append(selection[i]);bur.append(",");}buf.append(selection[seleetion.length-1]);}debugger.setText(buf.toString());}}protectedvoidgetSelectedIndices(intstart,intstop){if((start==-1)||(stop==-1)){returnnewint[0];}intguesses[]=newint[stop-start+1];intindex=0;for(inti=start;i<=stop;i++){if(model.isSelectedIndex(i)){guesses[index++]=i;}}intrealthing[]=newint[index];System.arraycopy(guesses,0,realthing,0,index);returnrealthing;}}}
进入题库练习
问答题请完成下列Java程序。程序的输出结果:a=6,b=5。注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下:publicclassex38_2{publicstaticvoidmain(Stringargs[]){inta=5,b=6;a=_________;b=a-b;a=_________;System.out.println("a="+a+"/tb="+b);}}
进入题库练习
问答题综合应用题下面是一个Applet程序,实现实心或者空心矩形的绘制。要求鼠标在Applet窗口中拖动实现矩形的绘制,可以选择填充或者空心,有按钮用来清空窗口中的图像。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:importjava.awt.*;importjava.applet.*;/**/publicclassex13_3extendsApplet{privateButtonbtnClear;privateCheckboxGroupcbg;privateCheckboxchk1,chk2;privateintupX,upY;privateintdownX,downY;privatebooleanbDraw,bClear,bStyle;publicvoidinit(){bDraw=false;bClear=false;bStyle=false;setLayout(null);cbg=newCheckboxGroup();chk1=newCheckbox("Hollow",cbg,true);chk2=newCheckbox("Filled",cbg,false);chk1.reshape(80,getSize().height-80,80,25);chk2.reshape(160,getSize().height-80,80,25);add(chk1);add(chk2);btnClear=newButton("clear");btnClear.reshape(240,getSize().height-80,80,25);add(btnClear);}publicvoidpaint(Graphicsg){if(bDraw){if(upX>downXelseg.drawRect(downX,downY,upX-downX,upY-downY);}elseif(upX>downXelseg.drawRect(upX,downY,downX-upX,upY-downY);}elseif(upXex13_3
进入题库练习
问答题System.out.println(total);
进入题库练习
问答题return s;
进入题库练习
问答题__________
进入题库练习
问答题本程序的功能是找出字符串"My name is Tom, I come from China."中的大写字母,并打印输出。 public class exam_31{ public static void main(String[] args){ String str="My name is Tom, I come from China."; ______; int i=0; while(i<len){ char c=str.charAt(i); if(______) System.out.print(c+" "); ______; } } }
进入题库练习
问答题本程序的功能是通过滑动条修改颜色的RGB值,从而控制颜色。程序中有一个面板、3个标签和3个滑动条,标签和滑动条一一对应,分别对应三原色红、绿、蓝,任意拖动其中一个滑动条,所对应的颜色值就会发生变化,面板的颜色也会对应发生变化,滑动条值的范围是0~255,如图所示。importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassexam_12extendsJFrameimplementsAdjustmentListener{publicexam_12(){setTitle("exam_12");setSize(300,200);addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});ContainercontentPane=______;JPanelp=newJPanel();p.setLayout(newGridLayout(3,2));p.add(redLabel=newJLabel("Red0"));p.add(red=newJScrollBar(Adjustable.HORIZONTAL,0,0,0,255));red.setBlockIncrement(16);red.addAdjustmentListener(this);p.add(greenLabel=newJLabel("Green0"));p.add(green=newJScrollBar(Adjustable.HORIZONTAL,0,0,0,255));green.setBlockIncrement(16);green.addAdjustmentListener(this);p.add(blueLabel=newJLabel("Blue0"));p.add(blue=newJScrollBar(Adjustable.HORIZONTAL,0,0,0,255));blue.setBlockIncrement(16);blue.addAdjustmentListener(this);contentPane.add(p,"South");colorPanel=newJPanel();colorPanel.setBackground(newColor(0,0,0));contentPane.add(colorPanel,"Center");}publicvoidadjustmentValueChanged(AdjustmentEventevt){redLabel.setText("Red"+red.getValue());greenLabel.setText("Green"+green.getValue());blueLabel.setText("Blue"+blue.getValue());colorPanel.setBackground(newColor(red.getValue(),green.getValue(),blue.getValue()));______;}publicstaticvoidmain(String[]args){JFramef=newexam_12();f.show();}privateJLabelredLabel;privateJLabelgreenLabel;privateJLabelblueLabel;privateJScrollBarred;privateJScrollBargreen;privateJScrollBarblue;privateJPanelcolorPanel;}
进入题库练习
问答题本程序的功能是读取exam_52_input.txt文件中颜色的RGB值,然后在窗口中画出对应颜色的圆,如图所示。importjava.awt.*;importjava.io.*;importjava.util.Vector;importjava.awt.event.*;classexam_52extendsFrameimplementsRunnable{intdotSize=30;vec=newVector();exam_52(Stringfilename){super("exam_52");addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){System.exit(0);}});try{BufferedReaderin=newBufferedReader(newInputStreamReader(newFileInputStream(filename)));Stringstr;while((str=in.readLine())==null){vec.addElement(str);}}catch(IOExceptione){}setSize(200,200);show();(newThread(this)).start();}publicvoidupdate(Graphicsg){Insetsinsets=this.getInsets();intx=0,y=0,rowCount=0;for(inti=0;i<vec.size();i++){g.setColor(Color.decode((String)vec.elementAt(i)));g.fillOval(insets.left+x-x%dotSize,insets.top+y-y%dotSize,dotSize,dotSize);x+=dotSize;if(rowCount==5){y+=dotSize;x=0;rowCount=0;}else{++rowCount;}}}publicvoidrun(){while(true){try{Thread.sleep(100);}catch(Exceptione){}repaint();}}publicstaticvoidmain(String[]args){newexam_52();}}
进入题库练习
问答题本程序将字符数组arr中属于字母(A~Z和a~z)的字符添加到一个字符串str的尾部。 public class exam_52{ public static void main(String[] args) { char arr[]={'1','C','d','E','T','s','$','W','#','@','i'}; String str; ______; int 1=arr.length; int i=0; do{ if(______) str=str.concat(String.valueOf(arr[i])); i++; } while(______); System.out.println(str); } }
进入题库练习
问答题请完成下列Java程序:用Swing实现一个简单的学生成绩管理器,显示出学生的姓名、Java成绩、C++成绩和这两门课的平均成绩,学生一共有4个人(Mike,Jack等)。要求可以修改学生的姓名和成绩,并且能够直接计算出平均成绩,如改变Mike的java成绩后,在平均成绩栏会自动更新为新的平均成绩。 注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 源程序文件清单如下: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.table.TableModel; public class ex03_2 extends JFrame { private JTable jt; private String[][] strData; public static void main(String[] args) { ex03_2 obj03_2=new ex03_2(); obj03_2.pack(); obj03_2.setVisible(true); } public ex03_2() { String[]columnNames={"name","java","C++","average"}; strData=new String[][]{ {"Mike","70.0","80.0","75.0"}, {"Jack","70.0","100.0","85.0"}, {"David","75.0","95.0","85.0"}, {"Tom","60.0","80.0","70.0"} }; jt=new JTable(strData,columnNames); jt.setPreferredScrollableViewportSize(new Dimension(400,200)); JScrollPane tp=new JScrollPane(jt); setTitle("ex03_2"); Container cp=getContentPane(); cp.add(tp,BorderLayout.CENTER); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { System.exit(0); } } jt.setSelectionMode(ListSelectionModel.SINGLE SELECTION); TableModel tm=jt.getModel(); tm.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent tme) { int nRow=tme.getFirstRow(); float fNum; float fSum=0; for(int i=1;i<=2;i++) { fNum=Float.parseFloat(_); fSum+=fNum; } float fAverage=fSum/2; ______; } } } }
进入题库练习
问答题下面是一个Applet程序,其功能是用一组坐标点绘制一个多边形,并通过沿坐标的垂直方向移动,把它移到窗口的下半部分,然后填充它。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 源程序文件清单如下: import java.awt.*; import java.applet.*; /* <applet code="ex11_3.class"width=800 height=400> </applet> */ public class ex11_3 extends Applet { int[] x = {15,50,100,160,120,190 }; int[] y = {15,100,30, 15, 80, 50 }; public void init() { setBackground (Color. lightGray); } public void paint (Graphics g) { int[] y2 = new int[6]; g. setColor (Color. red); Rectangle rect = getBounds(); {{U}}g.drawPolygon (x, y2,6){{/U}}; for(int i=0; i<6; i++) {{U}}y2[i] = y[i] + (rect.height / 2){{/U}}; {{U}}g. fillPolygon (x, y, 6){{/U}}; } } ex11_3. html <HTML> <HEAD> <TITLE>ex11_3</TITLE> </HEAD> <BODY> <applet code="ex11_3.class" width=800 height=400 > </applet> </BODY> </HTML>
进入题库练习
问答题e.printStackTrace();
进入题库练习
问答题本程序随机产生10个0~9的数字,并统计10个随机数中大于5的数字的个数。 public class exam_83{ public static void main(String[] args) { int result=0; int i=0; int randomNum; while(______){ randomNum=(int)(______); System.out.print(randomNum+","); if(randomNum>5) ______; i++; } System.out.println("The num(>5):"+result); } }
进入题库练习
问答题本程序判断score[]={89,93,60,59,78,91}中是否所有人的成绩都超过了80分,如果有人没有超过,则显示提示信息“有人未超过80分!”,否则显示“全部超过80分!” public class exam_58{ public static void main(String[] args) { int score[]={89,93,60,59,78,91}; int i=0; while(______){ if(score[i]<80) ______; i++; } if(______) System.out.println("有人未超过80分!"); else System.out.println("全部超过80分!"); } }
进入题库练习
问答题本程序的功能是读取命令行中参数的个数,并依次输出打印,如果没有输出参数,则打印输出“No para”。例如运行程序:java exam_41 par1 par2,则打印输出:Para 0:par1 Para1:par2。 public class exam_41{ public static void main(______args){ int num; ______; if(num==0) System.out.println("No para!"); for(int i=0; ______){ System.out.println("Para"+i+":"+args[i]); } } }
进入题库练习
问答题本程序的功能是输出0~20之间所有奇数的和。 public class exam_8{ public static void main(String[] args){ ______; int i=0; while(i<20){ if(______) sum=sum+i; ______; } System.out.println("sum="+sum); } }
进入题库练习