欢迎来到天天文库
浏览记录
ID:15149717
大小:77.00 KB
页数:7页
时间:2018-08-01
《java上机考试题目》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、上机考试题目1、冒泡排序(P114、例6.20)(注意到时候是按照什么顺序排序的)publicclassBubbleSort{publicstaticvoidmain(String[]args){int[]array={63,4,24,1,3,5};BubbleSortsorter=newBubbleSort();sorter.sort(array);}//冒泡排序publicvoidsort(int[]array){for(inti=1;i2、){if(array[j]>array[j+1]){inttemp=array[j];array[j]=array[j+1];array[j+1]=temp;}}showArray(array);}//遍历数组,并输出数组的元素。publicvoidshowArray(int[]array){for(inti=0;i3、取界面的录入信息,并输出到控制台)这个地方大家可能会有疑问,因为之前写的没有重置这个按钮功能,我把他添了进去,所以到时候抽到这道题目的时候,注意下,题目是否要有重置监听器!importjava.awt.event.*;importjavax.swing.*;importjavax.swing.border.Border;importjavax.swing.border.EtchedBorder;importjavax.swing.border.TitledBorder;publicclassSwingReigsterextendsJFra4、me{JPasswordFieldpwd=newJPasswordField();JTextFieldnameTxt=newJTextField();JTextAreaintrArea=newJTextArea();ButtonGroupgroup=newButtonGroup();JRadioButtonfRdo=newJRadioButton("男",true);JCheckBoxhobbyChk2=newJCheckBox("运动",true);JCheckBoxhobbyChk3=newJCheckBox("爬山");JCheck5、BoxhobbyChk=newJCheckBox("睡觉");JComboBoxedicbo=newJComboBox();publicSwingReigster(){this.init();}publicvoidinit(){this.setTitle("用户注册");this.setBounds(100,100,340,500);this.createUI();this.setVisible(true);this.setDefaultCloseOperation(EXIT_ON_CLOSE);getContentPane().setL6、ayout(null);}publicvoidcreateUI(){JPanelpanel=newJPanel();//添加边框Borderborder=BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);TitledBordertBorder=BorderFactory.createTitledBorder(border,"注册面板",TitledBorder.CENTER,TitledBorder.TOP);panel.setBorder(tBorder);panel.setL7、ayout(null);this.add(panel);//密码JLabelpwdLbl=newJLabel("输入密码:");pwdLbl.setBounds(10,80,60,25);panel.add(pwdLbl);pwd=newJPasswordField();pwd.setBounds(80,80,120,22);panel.add(pwd);//性别JLabelgenderLbl=newJLabel("性别:");genderLbl.setBounds(10,110,60,25);panel.add(genderLbl);g8、roup=newButtonGroup();fRdo.setBounds(80,110,50,25);group.add(fRdo);JRadioButtonmRdo=newJRadioBut
2、){if(array[j]>array[j+1]){inttemp=array[j];array[j]=array[j+1];array[j+1]=temp;}}showArray(array);}//遍历数组,并输出数组的元素。publicvoidshowArray(int[]array){for(inti=0;i3、取界面的录入信息,并输出到控制台)这个地方大家可能会有疑问,因为之前写的没有重置这个按钮功能,我把他添了进去,所以到时候抽到这道题目的时候,注意下,题目是否要有重置监听器!importjava.awt.event.*;importjavax.swing.*;importjavax.swing.border.Border;importjavax.swing.border.EtchedBorder;importjavax.swing.border.TitledBorder;publicclassSwingReigsterextendsJFra4、me{JPasswordFieldpwd=newJPasswordField();JTextFieldnameTxt=newJTextField();JTextAreaintrArea=newJTextArea();ButtonGroupgroup=newButtonGroup();JRadioButtonfRdo=newJRadioButton("男",true);JCheckBoxhobbyChk2=newJCheckBox("运动",true);JCheckBoxhobbyChk3=newJCheckBox("爬山");JCheck5、BoxhobbyChk=newJCheckBox("睡觉");JComboBoxedicbo=newJComboBox();publicSwingReigster(){this.init();}publicvoidinit(){this.setTitle("用户注册");this.setBounds(100,100,340,500);this.createUI();this.setVisible(true);this.setDefaultCloseOperation(EXIT_ON_CLOSE);getContentPane().setL6、ayout(null);}publicvoidcreateUI(){JPanelpanel=newJPanel();//添加边框Borderborder=BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);TitledBordertBorder=BorderFactory.createTitledBorder(border,"注册面板",TitledBorder.CENTER,TitledBorder.TOP);panel.setBorder(tBorder);panel.setL7、ayout(null);this.add(panel);//密码JLabelpwdLbl=newJLabel("输入密码:");pwdLbl.setBounds(10,80,60,25);panel.add(pwdLbl);pwd=newJPasswordField();pwd.setBounds(80,80,120,22);panel.add(pwd);//性别JLabelgenderLbl=newJLabel("性别:");genderLbl.setBounds(10,110,60,25);panel.add(genderLbl);g8、roup=newButtonGroup();fRdo.setBounds(80,110,50,25);group.add(fRdo);JRadioButtonmRdo=newJRadioBut
3、取界面的录入信息,并输出到控制台)这个地方大家可能会有疑问,因为之前写的没有重置这个按钮功能,我把他添了进去,所以到时候抽到这道题目的时候,注意下,题目是否要有重置监听器!importjava.awt.event.*;importjavax.swing.*;importjavax.swing.border.Border;importjavax.swing.border.EtchedBorder;importjavax.swing.border.TitledBorder;publicclassSwingReigsterextendsJFra
4、me{JPasswordFieldpwd=newJPasswordField();JTextFieldnameTxt=newJTextField();JTextAreaintrArea=newJTextArea();ButtonGroupgroup=newButtonGroup();JRadioButtonfRdo=newJRadioButton("男",true);JCheckBoxhobbyChk2=newJCheckBox("运动",true);JCheckBoxhobbyChk3=newJCheckBox("爬山");JCheck
5、BoxhobbyChk=newJCheckBox("睡觉");JComboBoxedicbo=newJComboBox();publicSwingReigster(){this.init();}publicvoidinit(){this.setTitle("用户注册");this.setBounds(100,100,340,500);this.createUI();this.setVisible(true);this.setDefaultCloseOperation(EXIT_ON_CLOSE);getContentPane().setL
6、ayout(null);}publicvoidcreateUI(){JPanelpanel=newJPanel();//添加边框Borderborder=BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);TitledBordertBorder=BorderFactory.createTitledBorder(border,"注册面板",TitledBorder.CENTER,TitledBorder.TOP);panel.setBorder(tBorder);panel.setL
7、ayout(null);this.add(panel);//密码JLabelpwdLbl=newJLabel("输入密码:");pwdLbl.setBounds(10,80,60,25);panel.add(pwdLbl);pwd=newJPasswordField();pwd.setBounds(80,80,120,22);panel.add(pwd);//性别JLabelgenderLbl=newJLabel("性别:");genderLbl.setBounds(10,110,60,25);panel.add(genderLbl);g
8、roup=newButtonGroup();fRdo.setBounds(80,110,50,25);group.add(fRdo);JRadioButtonmRdo=newJRadioBut
此文档下载收益归作者所有