java复习指南.doc

上传人:PIYPING 文档编号:11382923 上传时间:2021-08-01 格式:DOC 页数:8 大小:77KB
返回 下载 相关 举报
java复习指南.doc_第1页
第1页 / 共8页
java复习指南.doc_第2页
第2页 / 共8页
java复习指南.doc_第3页
第3页 / 共8页
java复习指南.doc_第4页
第4页 / 共8页
java复习指南.doc_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《java复习指南.doc》由会员分享,可在线阅读,更多相关《java复习指南.doc(8页珍藏版)》请在三一文库上搜索。

1、复习指南:考试题型: 1、选择题,30题 共45分 3、读程序 4题 共20分 4、简答题 2题 10分 3、编程题 25分 (2题) 复习重点:前13章 和22章选择题: 出题思路:围绕吴老师理论课所讲内容出题,以基本概念、基本语法以及类库知识等等: 这一部分大家要多看书,跟我之前考PASCAL有点像。 简答题复习重点:1、什么是多态,java中如何实现多态 2、什么叫容器布局,布局都有哪些3、Java中有一种小应用程序片,Applet,简述如何工作的4、迭代器的作用及其优势 5、内部类的作用6、类加载器的作用 7、设计和实现图形用户界面的工作主要有哪几方面?编程题的复习重点:1) 创建一个

2、名为Amphibian的类。由此继承产生一个称为Frog 的类。在基类中设置适当的方法。在main( )中,创建一个Frog并向上转型至Amphibian,然后说明所有方法都可以工作。(P140-16 )2) 编写一个名为Outer的类,它包含一个名为Inter的类。在Outer中添加一个方法,它返回一个Inter类型的对象。在main( )中,创建并初始化一个指向某个Inter对象的引用。(p191-1)3)创建一个Cycle类,它具有子类Unicycle、Bicycle和Tricycle,实现每一个类型的实例都可以经由ride( )方法向上转型为Cycle。4)编写一个类名为chap的应用

3、程序,用于演示JButton按钮操作,当单击左边的按钮时,中间的按钮和左边的按钮将失效,当右边的按钮由失效变成有效.5)编写一个应用程序,它包括一个文本域和三个按钮,单击每个按钮时在文本区显示不同的文字。6)、编写程序实现以下继承关系:动物类派生出鸟类、鱼类,鸟类派生出燕子类,鱼类派生出鲨鱼类。要求:每个类包含域“类别”、方法“返回类别”请读懂以下程序并给出运行结果:/程序1public class Guess /* * param args */public static void main(String args) / TODO Auto-generated method stub int

4、 a,b; for(a=14;a=90;a+) for(b=11;b50;b+) if(a-10)=(b-10)*4)&(a+10)%(b+10)=0) System.out.println(ag +a+ daf+b); /程序2class OverrideDemo void test() System.out.println( No parameters ); void test(int a) System.out.println(a: + a); void test(int a,int b) System.out.println(a and b: + a + + b); void test

5、(double a) System.out.println(double a: + a);class Override public static void main(String args) OverrideDemo ob = new OverrideDemo(); ob.test(); ob.test(10); ob.test(10,20); ob.test(123.25); /程序3import java.awt.*;import java.awt.event.*;import java.applet.*;public class ButtonApplet extends Applet

6、implements ActionListener int i1,i2; Button btn1,btn2; public void init() i1=0; i2=0; btn1=new Button(确定); btn2=new Button(取消); add(btn1); add(btn2); btn1.addActionListener(this); btn2.addActionListener(this); public void paint(Graphics g) g.setColor(Color.blue); g.drawString(你点击了确定+ i1+次,20,100); g

7、.setColor(Color.red); g.drawString(你点击了确定+ i2+次,20,120); public void actionPerformed(ActionEvent e) if(e.getSource()=btn1) i1+; if(e.getSource()=btn2) i2+; repaint(); /程序4interface WeaponString name = weapon;void attack();class Tank implements Weaponpublic void attack()System.out.println(Tank attack

8、);class Cannon implements Weaponpublic void attack()System.out.println(Cannon attack);class testWeaponpublic static void main(String args)Weapon wp; wp = new Tank();wp.attack();wp = new Cannon();wp.attack();/程序5public class Parcel2 class Contents private int i=11; public int value()return i; class D

9、estination private String lable; Destination(String whereTo) lable=whereTo; String readLabel()return lable; public Destination to(String s) return new Destination(s); public Contents contents() return new Contents(); public void ship(String dest) Contents c=contents(); Destination d=to(dest); System

10、.out.println(d.readLabel(); public static void main(String args) Parcel2 p=new Parcel2();p.ship(Tasmania);Parcel2 q=new Parcel2();Parcel2.Contents c=q.contents();Parcel2.Destination d=q.to(Borneo);/程序6:import java.util.*;public class SimpleCollection public static void main(String args) int b=0;Coll

11、ection c=new ArrayList(); for(int i=0;i10;i+) b=i+3; c.add(b); for(Integer i:c) System.out.print(i+ );/程序7:class WindowWindow(int marker)System.out.print(Window(+marker+);class HouseWindow w1=new Window(1);House()System.out.print(House();w3=new Window(33);Window w2=new Window(2);void f()System.out.p

12、rint(f();Window w3=new Window(3);public class orderOfInitialization public static void main(String args) House h=new House();h.f();/程序8public class ko public static void main(String args) int t, z=10; t=sum(z); System.out.println(sum=+t); static int sum(int x) if(x=1) return(1); else return(sum(x-1)

13、+x);/程序9public class TextComponetEvent extends Applet implements TextListener,ActionListener TextField tf; TextArea ta; public void init() tf=new TextField(45); ta=new TextArea(5,45); add(tf); add(ta); tf.addActionListener(this); tf.addTextListener(this); public void textValueChanged(TextEvent e) if

14、(e.getSource()=tf) ta.setText(TextField)e.getSource().getText(); public void actionPerformed(ActionEvent e) if(e.getSource()=tf) ta.setText(); /程序10import java.io.*;class Treeint height;Tree()System.out.println(Planting a seedling);height=0;Tree(int initialHeight)height=initialHeight;System.out.prin

15、tln(Creating new Tree that is+height+feet tall);void info()System.out.println(Tree is+height+feet tall);void info(String s)System.out.println(s+:Tree is+height+feet tall);public class OverLoading /* * param args */public static void main(String args) for(int i=0;i5;i+)Tree t=new Tree(i);t.info();t.i

16、nfo(overloaded method);import java.io.*;public class Score static int square(int x)return x*x;static double square(double x)return x*x;public static void main(String args) tryBufferedReader buf=new BufferedReader(new InputStreamReader(System.in);String s=buf.readLine();int n=Integer.parseInt(s);int nn=square(n);BufferedReader buff=new BufferedReader(new InputStreamReader(System.in);String ss=buff.readLine();double m=Double.parseDouble(ss);double mm=square(m);System.out.print(nn+n+mm);catch(IOException e);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1