77范文网 - 专业文章范例文档资料分享平台

java面向对象分析与设计复习(全答案版)(3)

来源:网络收集 时间:2020-06-24 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

}

数组b的长度:4 b[0]=1

2、分析下列程序得出输出结果。 class Chengji

{ float f(float x,float y) { return x*y; } }

class Xiangjia extends Chengji { float f(float x,float y) { return x+y ; }

}

public class Example4_16

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

sum=new Xiangjia(); float c=sum.f(4,6); System.out.println(c); } }

10.0

3、分析下列程序得出输出结果。 public class E3_2

{ public static void main( String args[] ) { char c='\\0'; }

}

for(int i=1;i<=4;i++) { switch(i) }

{ }

case 1: c='b'; System.out.print (c); case 2: c='e'; System.out.print (c);

break;

case 3: c='p'; System.out.print (c); default: System.out.print (\

beep!!

4、分析下列程序得出输出结果。 class A4_1 { int x;

public void setX( int x )

{

this.x=x;

}

public int getX() }

{ }

return x;

class B4_1

{ public void f(A4_1 a)

{ }

a.setX(100);

}

public class E4_1

{ public static void main( String args[] ) }

8 100

{ }

A4_1 a=new A4_1(); a.setX(8);

System.out.println(a.getX()); B4_1 b=new B4_1(); b.f(a);

System.out.println(a.getX());

5、分析下列程序得出输出结果。 class A4_2

{ int x=100,y=200; public void setX( int x ) { x=x;

}

public void setY( int y ) { this.y=y; }

} { }

return x+y;

public int getXYSum()

public class E4_2 { }

sum=-100

public static void main( String args[] ) { A4_2 a=new A4_2(); a.setX(-100); a.setY(-200); }

System.out.println(\

6、分析下列程序得出输出结果。 class A4_3 { int n;

static int sum=0; public void setN( int n ) { this.n=n; }

public int getSum()

{

for(int i=1;i<=n;i++) sum=sum+i; return sum;

} }

public class E4_3 { }

27

public static void main( String args[] )

{ A4_3 a1=new A4_3(),a2=new A4_3(); }

a1.setN(3); a2.setN(5);

int s1=a1.getSum(); int s2=a2.getSum();

System.out.println(s1+s2);

7、分析下列程序得出输出结果。 class A4_4 {

public int f( int x ) {

return x+1;

} }

class B4_4 extends A4_4

{ public int f( int x )

{ return x*x; } }

public class E4_4 { }

100

public static void main( String args[] ) { }

A4_4 a=new B4_4(); int m=a.f(10);

System.out.println(m) ;

8、分析下列程序得出输出结果。 class A4_5 {

double f(double x,double y ) { return x+y; }

static int g(int n ) {

return n*n;

} }

class B4_5 extends A4_5

{ double f(double x,double y )

{

double m=super.f(x,y); return m+x*y;

}

static int g(int n )

{ int m=A 4_5.g(n) ;

return m+n; }

}

public class E4_5 { }

98.0 12

public static void main( String args[] ) { B4_5 b=new B4_5(); }

System.out.println(b.f(10.0,8.0)) ; System.out.println(b.g(3)) ;

9、分析下列程序得出输出结果。

class Example5_4

{ public static void main(String args[])

{ String path=\ int index=path.lastIndexOf(\ String fileName=path.substring(index+1);

String newName=fileName.replaceAll(\ System.out.println(path);

System.out.println(fileName); System.out.println(newName); }

}

c:\\myfile\\pack\\result.txt result.txt result.doc

10、分析下列程序得出输出结果。 public class E5_1 { }

大学

public static void main( String args[] ) { String s=\广州大学松田学院\ }

char a=s.charAt(2),b=s.charAt(6); System.out.print (a); System.out.println(b);

11、分析下列程序得出输出结果。 import java.util.*; public class E5_2 {

public static void main( String args[] ) { int a[]={23,67,89,90,-987};

double b[]={12.89,90.87,34,678.987,-98.78,0.89}; Arrays.sort(a); Arrays.sort(b,1,4);

for(int i=0;i<=4;i++)

{ System.out.print (a[i]+ \}

System.out.println(\

for(int i=0;i<=b.length-1;i++) { System.out.print (b[i]+ \}

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库java面向对象分析与设计复习(全答案版)(3)在线全文阅读。

java面向对象分析与设计复习(全答案版)(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/jiaoyu/1125145.html(转载请注明文章来源)
上一篇:桥面混凝土铺装层施工
下一篇:城建史
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: