Java考试题之八】的更多相关文章

QUESTION 139 Giventhe following directory structure: bigProject |--source | |--Utils.java ||--classes |-- And the following command line invocation: javac -d classessource/Utils.java Assume the current directory is bigProject, what is theresult? A.  …
其实每个模式名称就表明了该模式的作用,代理模式就是多一个代理类出来,替原对象进行一些操作,比如我们在租房子的时候回去找中介,为什么呢?因为你对该地区房屋的信息掌握的不够全面,希望找一个更熟悉的人去帮你做,此处的代理就是这个意思.再如我们有的时候打官司,我们需要请律师,因为律师在法律方面有专长,可以替我们进行操作,表达我们的想法.先来看看关系图: 根据上文的阐述,代理模式就比较容易的理解了,我们看下代码: [java] view plaincopy public interface Sourcea…
本文采用eclipse 工具演示,如果您对eclipse 工具不了解,请先学习下 eclipse 工具的使用,这个里面只是简单的介绍下输出和注释: 安装完成eclipse 以后,双击进入 后一次点击 file -->new project 在出来的框上点击 输入项目名称,选择你安装eclipse 之前安装的jdk 的jre,本文使用1.8进行演示.然后点击finish 完成创建项目. 在完成的页面中我们输入如下代码,然后仔细阅读图片上的文字, public static void main(St…
QUESTION 230 Given: 10. class One { 11. public One foo() { return this; } 12. } 13. class Two extends One { 14. public One foo() { return this; } 15. } 16. class Three extends Two { 17. // insert method here 18. } Whichtwo methods, inserted individua…
QUESTION 177 Given: 1.     class TestException extends Exception { } 2.     class A { 3.     public String sayHello(String name) throws TestException { 4.     if(name == null) throw new TestException(); 5.     return "Hello " + name; 6.     } 7.…
QUESTION 134 Given:11. class Snoochy {12. Boochy booch;13. public Snoochy() { booch = new Boochy(this); }14. }15.16. class Boochy {17. Snoochy snooch;18. public Boochy(Snoochy s) { snooch = s; }19. } And the statements:21. public static void main(Str…
QUESTION 102 Given: 23. Object [] myObjects = { 24. new Integer(12), 25. new String("foo"), 26. new Integer(5), 27. new Boolean(true) 28. }; 29. Arrays.sort(myObjects); 30. for(int i=0;i<myObjects.length; i++) { 31. System.out.print(myObjects…
QUESTION 73 Given: 10: public class Hello { 11: String title; 12: int value; 13: public Hello() { 14: title += " World"; 15: } 16: public Hello(int value) { 17: this.value = value; 18: title = "Hello"; 19: Hello(); 20: } 21: } and: 30:…
QUESTION 46Given:11. public class Test {12. public static void main(String [] args) {13. int x = 5;14. boolean b1 = true;15. boolean b2 = false;16.17. if ((x == 4) && !b2 )18. System.out.print("1 ");19. System.out.print("2 ");2…
1.     public class GC { 2.     private Object o; 3.     private voiddoSomethingElse(Object obj) { o = obj; } 4.     public void doSomething() { 5.     Object o = new Object(); 6.     doSomethingElse(o); 7.     o = new Object(); 8.     doSomethingEls…