云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > JAVA期末复习资料

JAVA期末复习资料

  • 62 次阅读
  • 3 次下载
  • 2025/6/6 4:44:24

A、setSize()

B、setDefaultClose() C、pack()

D、setVisible() 三、程序阅读题

1、阅读下面的程序: class test {

public static void main(String[] args) {

int i = 1; int All = 0; for (;i<=10;i++) {

if (i%6==0) break;

if(i%2==0) {i=i+2;continue;} All = All + i; }

System.out.println(All); } }

上面的程序编译是否成功?如果编译出错,指出哪行出错,并说明理由;如果编译正确,运行结果是什么?

2、写出下列程序代码的运行结果: public class Example{

String str=new String(\ char ch[]={'J','a','v', 'a'};

public static void main(String args[]){ Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.println(ex.str);

System.out.println(new String(ex.ch)); }

public void change(String str,char ch[]){ str=\ch[0]= 'Y'; } }

3、仔细阅读下面的程序代码,编译和运行后,请写出该程序的输出结果。 class Game {

Game(int i) {

System.out.println(\ } }

class BoardGame extends Game { BoardGame(int i) { super(i);

System.out.println(\ } }

public class Chess extends BoardGame { Chess() {

super(11);

System.out.println(\ }

public static void main(String[] args) { Chess x = new Chess(); } }

4、仔细阅读下面的程序代码,编译和运行后,请写出该程序的输出结果。 import java.util.*; class Instrument {

protected void play() { System.out.println(\ static void tune(Instrument i) { i.play(); } }

// Wind object are instruments

// because then have the same interface: class Wind extends Instrument {

protected void play() { System.out.println(\ public static void main(String[] args) { Wind flute = new Wind(); Instrument.tune(flute); } }

5、仔细阅读下面的程序代码,编译和运行后,请写出该程序的输出结果。 interface Product {

static final String MAKER = \ static final String PHONE = \ public int getPrice(int id); }

class Shoe implements Product { public int getPrice(int id) { if ( id == 1 ) return 5; else

return 10; }

public String getMaker() { return MAKER; } }

public class Store { static Shoe hightop;

public static void init() { hightop = new Shoe(); }

public static void main(String[] args) { init();

getInfo(hightop); orderInfo(hightop); }

public static void getInfo(Shoe item) {

System.out.println(\ System.out.println(\ }

public static void orderInfo(Product item) {

System.out.println(\+ \

System.out.println(\ } }

6、仔细阅读下面的程序代码,编译和运行后,请写出该程序的输出结果。 class Father{

String name=\ int age=45; int getAge(){ return age; }

String getName(){ return name; }

void setAge(int a){ age = a; } }

class Child extends Father{ String name=\ int age=18;

int getAge(){ return age+1; } }

class Test2{

public static void main(String args[]){ Father p=new Child();

System.out.println(p.getAge()); p.setAge(30); System.out.println(p.getAge());

System.out.println(p.getName()); } }

7、阅读下面的程序:

1) public class test 2) {

3) public static void main(String args[]) 4) {

5) Bird.Fly(3); 6) } 7) }

8) class Bird{ 9) int Type = 2;

10) private static void Fly(int an_Type){ 11) Type = an_Type;

12) System.out.println(\13) } 14) }

上面的程序编译是否成功?如果编译出错,指出哪行出错,并说明理由;如果编译正确,运行结果是什么? 8、阅读下面程序: class Person{

public Person(){

System.out.println(\ }

public Person(String s){ this();

System.out.println(\ } }

public class Who extends Person{ public Who(){

this(\

搜索更多关于: JAVA期末复习资料 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

A、setSize() B、setDefaultClose() C、pack() D、setVisible() 三、程序阅读题 1、阅读下面的程序: class test { public static void main(String[] args) { int i = 1; int All = 0; for (;i<=10;i++) { if (i%6==0) break; if(i%2==0) {i=i+2;continue;} All = All + i; } System.out.println(All); } } 上面的程序编译是否成功?如果编译出错

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com