java(程序结果).docx_第1页
java(程序结果).docx_第2页
java(程序结果).docx_第3页
java(程序结果).docx_第4页
java(程序结果).docx_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1.int a=2;System.out.println(a+);System.out.println(a);System.out.println(+a);结果:2342.int x=4;System.out.println(value is+(x4)?99.99:9);结果: value x=125;System.out.println(x%2);System.out.println(x/10);System.out.println(x%3=0);结果:112False4.System.out.print(7%-2+t);System.out.print(7%2+t);System.out.print(-7%2+t);System.out.print(-7%-2+t);System.out.print(7.2%2.8=+7.2%2.8);结果:11-1-17.2%2.8=1.60000000000000055.int a=6,b=7,c=8;double d=3.14;String x=hello;System.out.println(a+b+x+c+d);结果:13hello83.146.char a=6;int d =a-0;System.out.println(a+1);System.out.println(d+1);结果:5577.String c=red;switch (c) default:System.out.println(white);break;case red:System.out.println(red);break;case blue:System.out.println(blue);break;结果:red8.outer:for (int i = 1; i 3; i+) for (int j = 1; j 4; j+) if (i=1 & j=2)continue outer;System.out.println(i=+i+ j=+j);结果:i=1 j=1i=2 j=1i=2 j=2i=2 j=39.int j=0;do if(j=5) continue;System.out.print(j+ );j+; while (j1)if(a2)d=4;elsed=2;else if(bc)d=3;else d=1;System.out.println(d=+d);结果:d=112.int m=8,n=5;while (m2) if(mn)m=m-n;elsen=n-m;System.out.println(m);结果:113.int x=1,y=1,z=1;if(x-=1 & y+=1 | z+=1)System.out.println(x=+x+,y=+y+,z=+z);结果:x=0,y=2,z=114.int x =23659;String m=resule=;while (x0) m=m+x%10;x=x/10;System.out.println(m);结果:resule=9563215.int i=0,j=5;top:for(;)i+;for(;)if(i-j) break top;System.out.println(i=+i+,j=+j);结果:i=1,j=016.int a = new int6;for (int m = 0; m a.length; m+) am=m+1;System.out.print(am);if(m%3=0)System.out.println();结果:12345617.public static void main(String args) int s=f(3)+f(2);System.out.println(s=+s);public static int f(int k)int m=1,r=1;while (m=k) r=r*m;m+;return r;结果:s=818.public static void main(String args) int a=1,2,3,4;for (int i = 0; i 0)return n+fun(k,n-1);elsereturn 0;结果:621.class Parentprotected static int count=0;public Parent()count+;public class Child extends Parentpublic Child()count+;public static void main(String args) Child x =new Child();System.out.println(count=+count);结果:count=222.public class A protected void test(float x)System.out.println(test(float):+x);protected void test(Object obj)System.out.println(test(Object):+obj);protected void test(String str)System.out.println(test(String):+str);public static void main(String args) A a1 = new A();a1.test(hello);a1.test(5);结果:test(String):hellotest(float):5.023.class exSuperpublic void func(String p,String s)System.out.println(p);public class example extends exSuperpublic void func(String p,String s)System.out.println(p+:+s);public static void main(String args) exSuper e1= new exSuper();e1.func(hello1, hi1);exSuper e2 = new example();e2.func(hello2, hi2);结果: hello1hello2:hi224.class Treeclass Pine extends Treeclass Oak extends Treepublic class Forest public static void main(String args) Tree tree = new Pine();if(tree instanceof Pine)System.out.println(Pine);if(tree instanceof Tree)System.out.println(Tree);if(tree instanceof Oak)System.out.println(Oak);elseSystem.out.println(Oops);结果:PineTreeOops25.public class isEqual int x;public isEqual(int x1)x=x1;public static void main(String args) isEqual m1= new isEqual(4);isEqual m2= new isEqual(4);isEqual m3=m2;m3.x=6;System.out.println(m1=m2 is +(m1=m2);System.out.println(m2=m3 is +(m2=m3);System.out.println(m1.x=m2.x is +(m1.x=m2.x);System.out.println(m1.equals(m2)=+m1.equals(m2);结果:m1=m2 is falsem2=m3 is truem1.x=m2.x is falsem1.equals(m2)=false25.abstract class Avoid m1()System.out.println(m1();abstract void m2();interface Bvoid n();public class test extends A implements Bvoid m2()System.out.println(call m2();public void n()System.out.println(call n();public static void main(String args) test obj = new test();obj.m1();obj.m2();obj.n();结果:m1()call m2()call n()26.public final class testclass Innervoid test()if(test.this.flag)sample();elseSystem.out.println(inner test);private boolean flag=false;public void sample()System.out.println(sample);public test()flag=true;(new Inner().test();public static void main(String args) new test();结果:erface Afloat v=2.0f;void init();class Bint v=3;void output()System.out.println(v);public class test extends B implements Apublic void init()System.out.println(do init);public static void main(String args) test x = new test();x.init();x.output();x.printV();void printV()System.out.println(super.v+A.v);结果:do init35.027.public class Ex2 public static void main(String args) String str=null;try if(str.length()=0)System.out.print(The);System.out.print( Cow); catch (Exception e) System.out.print( and);System.exit(0);finallySystem.out.print( Chicken);System.out.println( show);结果: and28.public class A static int some()try System.out.println(try);return 1;finally System.out.println(finally);public static void main(String args) System.out.println(some();结果:tryfinally129.public class Unchecked public static void main(String args)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论