欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    JAVA期末考试整理资料.docx

    • 资源ID:1991383       资源大小:20.67KB        全文页数:41页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    JAVA期末考试整理资料.docx

    1、JAVA期末考试整理资料JAVA期末整理资料1、import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Test extends JFrame int x1,y1,x2,y2;public Test()setVisible(true);setSize(300,300) ;addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e)System.exit(0) ; );addMouseListener(ne

    2、w MouseAdapter() public void mousePressed(MouseEvent e)x1=e.getX();y1=e.getY(); );addMouseMotionListener(new MouseMotionAdapter() public void mouseDragged(MouseEvent e)x2=e.getX() ;y2=e.getY() ;repaint(); );public void paint(Graphics g)g.drawLine(x1,y1,x2,y2);x1=x2;y1=y2;public static void main(Stri

    3、ng args)new Test();2、class Transport int speed,load; public Transport(); public Transport(int speed,int load) this.speed = speed; this.load = load; public static void main(String args) class vehicle extends Transport int wheels,weight; public vehicle(); public vehicle(int speed,int load,int wheels,i

    4、nt weight) super(speed,load); this.wheels = wheels; this.weight = weight; class Airplane extends Transport int engintype,enginnumber; public Airplane(); public Airplane(int speed,int load,int engintype,int enginnumber) super(speed,load); this.engintype = engintype; this.enginnumber = enginnumber; 3、

    5、class TestRead public static void main(Stringargs) int x=0; try x=System.in.read(); catch(Exception e) while(x!=q) System.out.println(char)x); try x=System.in.read(); catch(Exception e) 4、class AA public void exchange( int a,intarray) a=50; array1=30; class testAA public static void main(String args

    6、) int aa=3; int array=1,2,3; AA a=new AA(); a.exchange(aa,array); System.out.println(aa); System.out.println(array1); 5、public class Person public String name; public int age; public String addr; Person () public Person(String name,int age) this.name=name; this.age=age; public Person(String name,int

    7、 age,String addr) this(name,age); this.addr=addr; public void getInfo() System.out.println(name); System.out.println(age); class Student extends Person public int grade; public student() public Student(String name,int age,int grade) super(name,age); this.grade=grade; public void getInfo() super.getI

    8、nfo(); System.out.println(grade); public static void main(Srtingargs) Student s=new Student(student,16,2); s.getInfo(); 6、interface StudentManageInterface double money = 0; void setFee(double money); double getFee();interface TeacherManageInterface double tmoney = 0; void setPay(double tmoney); doub

    9、le getPay();class Graduate implements StudentManageInterface,TeacherManageInterface String name,sex; int age; double fee,pay; public Graduate(); public Graduate(String name,String sex,int age,double fee,double pay) setPay(pay); setFee(fee); public void setPay(double pay) this.pay=pay; public double

    10、getPay() return pay; public void setFee(double fee) this.fee=fee; public double getFee() return fee; public class Question7 public static void main(String agrs) Graduate g1 = new Graduate(zhangsan,男,17,12,1500); if(g1.getFee()*12 - g1.getPay()2000 ) System.out.println(provide a loan); 7、package test

    11、1;import java.awt.*;import java.awt.event.*;public class Integration implements TextListener,ActionListener Frame f; TextField tfDividend,tfDivisor; Label lb; Button btCount,btClean; public static void main(String args) new Integration(); public Integration() f=new Frame(Integration); f.setLayout(ne

    12、w GridLayout(4,1); tfDividend=new TextField(); tfDividend.addTextListener(this);/textValueChanged(TextEvent e) tfDivisor=new TextField(); tfDivisor.addTextListener(this); lb=new Label(); btCount=new Button(除); btCount.setActionCommand(btCount); btCount.setBackground(Color.blue); btCount.addActionLis

    13、tener(this);/actionPerformed(ActionListener e) btClean=new Button(清除); btClean.setActionCommand(btClean); btClean.setForeground(Color.red); btClean.addActionListener(this); Panel p=new Panel(new GridLayout(1,2); p.add(btCount); p.add(btClean); f.add(tfDividend); f.add(tfDivisor); f.add(lb); /f.add(b

    14、tCount); /f.add(btClean); f.add(p); /f.addWindowListener(this); f.addWindowListener( new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); f.pack(); f.setVisible(true); public void textValueChanged(TextEvent e) lb.setText(tfDividend.getText(); public void actionPerformed(Ac

    15、tionEvent e) String cmd=e.getActionCommand(); if(cmd.equals(btCount) lb.setText(Double.parseDouble(tfDividend.getText()+ / +Double.parseDouble(tfDivisor.getText()+=+divide(Double.parseDouble(tfDividend.getText(),Double.parseDouble(tfDivisor.getText(); else if(cmd.equals(btClean) tfDividend.setText()

    16、; tfDivisor.setText(); lb.setText(); public double divide(double x,double y) return x/y; 8、package test1;import java.awt.*;import java.awt.event.*;public class Integration implements TextListener,ActionListener Frame f; TextField tfDividend,tfDivisor; Label lb; Button btCount,btClean; public static

    17、void main(String args) new Integration(); public Integration() f=new Frame(Integration); f.setLayout(new GridLayout(4,1); tfDividend=new TextField(); tfDividend.addTextListener(this);/textValueChanged(TextEvent e) tfDivisor=new TextField(); tfDivisor.addTextListener(this); lb=new Label(); btCount=ne

    18、w Button(除); btCount.setActionCommand(btCount); btCount.setBackground(Color.blue); btCount.addActionListener(this);/actionPerformed(ActionListener e) btClean=new Button(清除); btClean.setActionCommand(btClean); btClean.setForeground(Color.red); btClean.addActionListener(this); Panel p=new Panel(new Gr

    19、idLayout(1,2); p.add(btCount); p.add(btClean); f.add(tfDividend); f.add(tfDivisor); f.add(lb); /f.add(btCount); /f.add(btClean); f.add(p); /f.addWindowListener(this); f.addWindowListener( new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); f.pack(); f.setVisible(true); pu

    20、blic void textValueChanged(TextEvent e) lb.setText(tfDividend.getText(); public void actionPerformed(ActionEvent e) String cmd=e.getActionCommand(); if(cmd.equals(btCount) lb.setText(Double.parseDouble(tfDividend.getText()+ / +Double.parseDouble(tfDivisor.getText()+=+divide(Double.parseDouble(tfDivi

    21、dend.getText(),Double.parseDouble(tfDivisor.getText(); else if(cmd.equals(btClean) tfDividend.setText(); tfDivisor.setText(); lb.setText(); public double divide(double x,double y) return x/y; 9、import java.awt.*;import java.awt.event.*;public class FBL implements ActionListener Frame f; Button b1,b2

    22、; Label lb; public FBL() f=new Frame(FBL); f.setLayout(new GridLayout(3,1); b1=new Button(b1); b2=new Button(b2); b1.addActionListener(this); b2.addActionListener(this); lb=new Label(); f.add(b1); f.add(b2); f.add(lb); f.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e)

    23、System.exit(0); ); f.pack(); f.setVisible(true); public void actionPerformed(ActionEvent e) Button b=(Button)e.getSource(); lb.setText(b.getLabel(); public static void main(String args) new FBL(); 10、import java.io.*;public class FileRuntimeTest public static void main(String args) File f=new File(a

    24、rgs1); if(f.exists() try Process p=null; p=Runtime.getRuntime().exec(args); Thread.sleep(5000); p.destroy(); catch(Exception e) e.printStackTrace(); else try f.createNewFile(); catch(Exception e) System.out.println(e.getMessage(); 11、import java.awt.*;import java.awt.event.*;import java.io.*;public

    25、class MyNotepad extends WindowAdapter implements ActionListener Frame f; Button btn; TextArea ta; String filename; public static void main(String args) new MyNotepad(args0); public MyNotepad(String filename) this.filename=filename; f=new Frame(filename); f.addWindowListener(this); btn=new Button(sav

    26、e); btn.addActionListener(this); ta=new TextArea(10,40); f.add(ta,BorderLayout.CENTER); f.add(btn,BorderLayout.SOUTH); f.pack(); f.setVisible(true); public void actionPerformed(ActionEvent e) try FileWriter fout=new FileWriter(filename,false); fout.write(ta.getText(); fout.close(); catch(IOException

    27、 ioe) System.err.println(ioe); public void windowClosing(WindowEvent e) System.exit(0); 12、import java.awt.*;import java.awt.event.*;import java.io.*;public class MyNotepad extends WindowAdapter implements ActionListener Frame f; Button btn; TextArea ta; String filename; public static void main(String args) new MyNotepad(args0); public MyNotepad(String filename) this.filename=filename; f=new Frame(filename); f.addWindowListener(this); btn=n


    注意事项

    本文(JAVA期末考试整理资料.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开