JAVA编程思想课后习题答案.doc

上传人:飞****9 文档编号:134138124 上传时间:2020-06-02 格式:DOC 页数:10 大小:36.50KB
返回 下载 相关 举报
JAVA编程思想课后习题答案.doc_第1页
第1页 / 共10页
JAVA编程思想课后习题答案.doc_第2页
第2页 / 共10页
JAVA编程思想课后习题答案.doc_第3页
第3页 / 共10页
JAVA编程思想课后习题答案.doc_第4页
第4页 / 共10页
JAVA编程思想课后习题答案.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《JAVA编程思想课后习题答案.doc》由会员分享,可在线阅读,更多相关《JAVA编程思想课后习题答案.doc(10页珍藏版)》请在金锄头文库上搜索。

1、Java编程思想(第四版)习题答案第二章练习1:public class PrimitiveTest static int i;static char c;public static void main(String args) System.out.println(int = + i);System.out.println(char = + c);练习2:public class HelloWorld public static void main(String args) System.out.println(Hello World!);练习3:public class ATNTest p

2、ublic static void main(String args) class ATypeName int i;double d;boolean b;void show() System.out.println(i);System.out.println(d);System.out.println(b);ATypeName a = new ATypeName();a.i = 3;a.d = 2.71828;a.b = false;a.show();练习4:public class DataOnlyTest public static void main(String args) class

3、 DataOnly int i;double d;boolean b;void show() System.out.println(i);System.out.println(d);System.out.println(b);DataOnly data = new DataOnly();data.i = 3;data.d = 2.71828;data.b = false;data.show();练习5:public class DOTest2 public static void main(String args) class DataOnly int i;double d;boolean b

4、;void show() System.out.println(i);System.out.println(d);System.out.println(b);DataOnly data = new DataOnly();data.i = 234;data.d = 2.1234545;data.b = true;data.show();练习6:public class StorageTest public static void main(String args) class StoreStuff int storage(String s) return s.length() * 2;Store

5、Stuff x = new StoreStuff();System.out.println(x.storage(hi);练习7:class StaticTest static int i = 47;class Incrementable static void increment() StaticTest.i+; public class ITest public static void main(String args) System.out.println(StaticTest.i= + StaticTest.i);StaticTest st1 = new StaticTest();Sta

6、ticTest st2 = new StaticTest();System.out.println(st1.i= + st1.i);System.out.println(st2.i= + st2.i);Incrementable sf = new Incrementable();sf.increment();System.out.println(After sf.increment() called: );System.out.println(st1.i = + st1.i);System.out.println(st2.i = + st2.i);Incrementable.increment

7、();System.out.println(After Incrementable.increment called: );System.out.println(st1.i = + st1.i);System.out.println(st2.i = + st2.i);练习8:class StaticTest static int i = 47;class Incrementable static void increment() StaticTest.i+; public class OneStaticTest public static void main(String args) Syst

8、em.out.println(StaticTest.i= + StaticTest.i);StaticTest st1 = new StaticTest();StaticTest st2 = new StaticTest();System.out.println(st1.i= + st1.i);System.out.println(st2.i= + st2.i);Incrementable.increment();System.out.println(After Incrementable.increment() called: );System.out.println(st1.i = + s

9、t1.i);System.out.println(st2.i = + st2.i);Incrementable.increment();System.out.println(After Incrementable.increment called: );System.out.println(st1.i = + st1.i);System.out.println(st2.i = + st2.i);st1.i = 3;System.out.println(After st1.i = 3, );System.out.println(st1.i = + st1.i);System.out.printl

10、n(st2.i = + st2.i);System.out.println(Create another StaticTest, st3.);StaticTest st3 = new StaticTest();System.out.println(st3.i = + st3.i);练习9:public class AutoboxTest public static void main(String args) boolean b = false;char c = x;byte t = 8;short s = 16;int i = 32;long l = 64;float f = 0.32f;d

11、ouble d = 0.64;Boolean B = b;System.out.println(boolean b = + b); System.out.println(Boolean B = + B); Character C = c;System.out.println(char c = + c);System.out.println(Character C = + C);Byte T = t;System.out.println(byte t = + t);System.out.println(Byte T = + T);Short S = s;System.out.println(sh

12、ort s = + s);System.out.println(Short S = + S);Integer I = i;System.out.println(int i = + i);System.out.println(Integer I = + I);Long L = l;System.out.println(long l = + l);System.out.println(Long L = + L);Float F = f;System.out.println(float f = + f);System.out.println(Float F = + F);Double D = d;S

13、ystem.out.println(double d = + d);System.out.println(Double D = + D);练习10:public class CommandArgTest public static void main(String args) System.out.println(args0 = + args0);System.out.println(args1 = + args1);System.out.println(args2 = + args2);练习11:public class Rainbow public static void main(String args) AllTheColorsOfTheRainbow atc = new AllTheColorsOfTheRainbow();System.out.println(atc.anIntegerRepresentingColors = + atc.anIntegerRepresent

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > IT计算机/网络 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号