﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-礼必风-文章分类-专业考试题库</title><link>http://www.blogjava.net/bily/category/17315.html</link><description>IT!=it</description><language>zh-cn</language><lastBuildDate>Fri, 25 Jan 2008 04:16:52 GMT</lastBuildDate><pubDate>Fri, 25 Jan 2008 04:16:52 GMT</pubDate><ttl>60</ttl><item><title>java面试笔试题整理</title><link>http://www.blogjava.net/bily/articles/168520.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Tue, 18 Dec 2007 08:33:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/168520.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/168520.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/168520.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/168520.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/168520.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp; JAVA相关基础知识　　1、面向对象的特征有哪些方面　　（1）抽象（abstract）：　　抽象就是忽略一个主题中与当前目标无关的那些方面，以便更充分地注意与当前目标有关的方面。抽象并不打算了解全部问题，而只是选择其中的一部分，暂时不用部分细节。抽象包括两个方面，一是过程抽象，二是数据抽象。　　（2）继承（inheritance）：　　继承...&nbsp;&nbsp;<a href='http://www.blogjava.net/bily/articles/168520.html'>阅读全文</a><img src ="http://www.blogjava.net/bily/aggbug/168520.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2007-12-18 16:33 <a href="http://www.blogjava.net/bily/articles/168520.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA题库格林模拟试题（三）</title><link>http://www.blogjava.net/bily/articles/81727.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Fri, 17 Nov 2006 03:30:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81727.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81727.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81727.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81727.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81727.html</trackback:ping><description><![CDATA[
		<p>JAVA题库:格林模拟试题三<br />Questions<br />________________________________________<br />Question 1)Which of the following are legal statements?</p>
		<p>1) float f=1/3;</p>
		<p>2) int i=1/3;</p>
		<p>3) float f=1.01;</p>
		<p>4) double d=999d;<br />________________________________________</p>
		<p>Question 2)Which of the following are Java keywords?</p>
		<p>1) NULL</p>
		<p>2) new</p>
		<p>3) instanceOf</p>
		<p>4) wend<br />________________________________________</p>
		<p>Question 3)Which of the following are valid statements?</p>
		<p>1) System.out.println(1+1);</p>
		<p>2) int i=2+'2';</p>
		<p>3) String s="on"+'one';</p>
		<p>4) byte b=255;<br />________________________________________</p>
		<p>Question 4)Which of the following statements are true?</p>
		<p>1) The garbage collection algorithm in Java is vendor implemented</p>
		<p>2) The size of primitives is platform dependent</p>
		<p>3) The default type for a numerical literal with decimal component is a float.</p>
		<p>4) You can modify the value in an Instance of the Integer class with the setValue method<br />________________________________________</p>
		<p>Question 5)Which of the following are true statements?</p>
		<p>1) I/O in Java can only be performed using the Listener classes</p>
		<p>2) The RandomAccessFile class allows you to move directly to any point a file.</p>
		<p>3) The creation of a named instance of the File class creates a matching file in the underlying operating system only when the close method is called.</p>
		<p>4) The characteristics of an instance of the File class such as the directory separator, depend on the current underlying operating system<br />________________________________________</p>
		<p>Question 6)Which of the following statements are true?</p>
		<p>1) The instanceof operator can be used to determine if a reference is an instance of a class, but not an interface.</p>
		<p>2) The instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper class</p>
		<p>3) The instanceof operator will only determine if a reference is an instance of a class immediately above in the hierarchy but no further up the inheritance chain</p>
		<p>4) The instanceof operator can be used to determine if one reference is of the same class as another reference thus<br />________________________________________</p>
		<p>Question 7)Which of the following statements are true?</p>
		<p>1) An interface can only contain method and not variables</p>
		<p>2) Interfaces cannot have constructors</p>
		<p>3) A class may extend only one other class and implement only one interface</p>
		<p>4) Interfaces are the Java approach to addressing its lack of multiple inheritance, but require implementing classes to create the functionality of the Interfaces.<br />________________________________________</p>
		<p>Question 8)Which of the following are valid statements</p>
		<p>1) public class MyCalc extends Math</p>
		<p>2) Math.max(s);</p>
		<p>3) Math.round(9.99,1);</p>
		<p>4)Math.mod(4,10);<br />________________________________________</p>
		<p>Question 9)Which of the following are methods of the Runnable interface</p>
		<p>1) run</p>
		<p>2) start</p>
		<p>3) yield</p>
		<p>4) stop<br />________________________________________</p>
		<p>Question 10)Which of the following statements are true?</p>
		<p>1) A byte can represent between -128 to 127</p>
		<p>2) A byte can represent between -127 to 128</p>
		<p>3) A byte can represent between -256 to 256</p>
		<p>4) A char can represent between -2x2 pow 16 2 x2 pow 16 - 1<br />________________________________________</p>
		<p>Question 11)What will happen when you attempt to compile and run the following code</p>
		<p>class Base{</p>
		<p>public void Base(){</p>
		<p>System.out.println("Base");</p>
		<p>}</p>
		<p>}</p>
		<p>public class In extends Base{</p>
		<p>public static void main(String argv[]){</p>
		<p>In i=new In();</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile time error Base is a keyword</p>
		<p>2) Compilation and no output at runtime</p>
		<p>3) Output of Base</p>
		<p>4) Runtime error Base has no valid constructor<br />________________________________________</p>
		<p>Question 12)You have a public class called myclass with the main method defined as follows</p>
		<p>public static void main(String parm[]){</p>
		<p>System.out.println(parm[0]);</p>
		<p>}</p>
		<p>If you attempt to compile the class and run the program as follows</p>
		<p>java myclass hello</p>
		<p>What will happen?</p>
		<p>1) Compile time error, main is not correctly defined</p>
		<p>2) Run time error, main is not correctly defined</p>
		<p>3) Compilation and output of  java</p>
		<p>4) Compilation and output of hello<br />________________________________________</p>
		<p>Question 13)Which of the following statements are true?</p>
		<p>1) If a class has any abstract methods it must be declared abstract itself.</p>
		<p>2) All methods in an abstract class must be declared as abstract</p>
		<p>3) When applied to a class, the final modifier means it cannot be sub-classed</p>
		<p>4) transient and volatile are Java modifiers<br />________________________________________</p>
		<p>Question 14)Which of the following are valid methods?</p>
		<p>1) public static native void amethod(){}</p>
		<p>2) public static void amethod(){}</p>
		<p>3) private protected void amethod(){}</p>
		<p>4) static native void amethod();<br />________________________________________</p>
		<p>Question 15)Which of the following statements are true?</p>
		<p>1) Constructors cannot have a visibility modifier</p>
		<p>2) Constructors can be marked public and protected, but not private</p>
		<p>3) Constructors can only have a primitive return type</p>
		<p>4) Constructors are not inherited<br />________________________________________</p>
		<p>Question 16)What will happen when you attempt to compile and run the following class?</p>
		<p>class Base{</p>
		<p>Base(int i){System.out.println("Base");}</p>
		<p>}</p>
		<p>class Severn extends Base{</p>
		<p>public static void main(String argv[]){Severn s = new Severn();}</p>
		<p>void Severn(){System.out.println("Severn");}</p>
		<p>}</p>
		<p>1) Compilation and output of the string "Severn" at runtime</p>
		<p>2) Compile time error</p>
		<p>3) Compilation and no output at runtime</p>
		<p>4) Compilation and output of the string "Base"<br />________________________________________</p>
		<p>Question 17)Which of the following statements are true?</p>
		<p>1) static methods do not have access to the implicit variable called this</p>
		<p>2) A static method may be called without creating an instance of its class</p>
		<p>3) A static method may not be overriden to be non-static</p>
		<p>4) A static method may not be overloaded<br />________________________________________</p>
		<p>Question 18)Which of the following will compile without error?</p>
		<p>1)char c='1';</p>
		<p>System.out.println(c&gt;&gt;1);</p>
		<p>2)Integer i=Integer("1");</p>
		<p>System.out.println(i&gt;&gt;1);</p>
		<p>3)int i=1;</p>
		<p>System.out.println(i&lt;&lt;&lt;1);</p>
		<p>4)int i=1;</p>
		<p>System.out.println(i&lt;&lt;1);<br />________________________________________</p>
		<p>Question 19)Which of the following are true?</p>
		<p>1) A component may have only one event listener attached at a time</p>
		<p>2) An event listener may be removed from a component</p>
		<p>3) The ActionListener interface has no corresponding Adapter class</p>
		<p>4) The processing of an event listener requires a try/catch block<br />________________________________________</p>
		<p>Question 20)Which of the following are Java keywords?</p>
		<p>1) sizeof</p>
		<p>2) main</p>
		<p>3) transient</p>
		<p>4) volatile<br />________________________________________</p>
		<p>Question 21)Which of the following statements are true?</p>
		<p>1) The default constructor has a return type of void</p>
		<p>2) The default constructor takes a parameter of void</p>
		<p>3) The default constructor takes no parameters</p>
		<p>4) The default constructor is not created if the class has any constructors of its own.<br />________________________________________</p>
		<p>Question 22)Which of the following statements are true?</p>
		<p>1) All of the variables in an interface are implicitly static</p>
		<p>2) All of the variables in an interface are implicitly final</p>
		<p>3) All of the methods in an interface are implicitly abstract</p>
		<p>4) A method in an interface can access class level variables<br />________________________________________</p>
		<p>Question 23)Which of the following statements are true?</p>
		<p>1) The String class is implemented as a char array, elements are addressed using the stringname[] convention</p>
		<p>2) The + operator is overloaded for concatenation for the String class</p>
		<p>3) Strings are a primitive type in Java and the StringBuffer is used as the matching wrapper type</p>
		<p>4) The size of a string can be retrieved using the length property<br />________________________________________</p>
		<p>Question 24)Which of the following statements are true?</p>
		<p>1) A method in an interface must not have a body</p>
		<p>2) A class may extend one other class plus at most one interface</p>
		<p>3) A class may extends at most one other class plus implement many interfaces</p>
		<p>4) An class accesses an interface via the keyword uses<br />________________________________________</p>
		<p>Question 25)Which of the following statements are true?</p>
		<p>1) The following statement will produce a result of 1. System.out.println( -1 &gt;&gt;&gt;2);</p>
		<p>2) Performing an unsigned left shift (&lt;&lt;&lt;) on a negative number will always produce a negative number result</p>
		<p>3) The following statement will produce a result of zero, System.out.println(1 &gt;&gt;1);</p>
		<p>4) All the Java integral types are signed numbers<br />________________________________________</p>
		<p>Question 26)Which of the following statements are true?</p>
		<p>1) The elements in a Java array can only be of primitive types, not objects</p>
		<p>2) Arrays elements are initialized to default values wherever they are created using the keword new</p>
		<p>3) An array may be dynamically resized using the setSize method</p>
		<p>4) You can find out the size of an array using the size method<br />________________________________________</p>
		<p>Question 27)Given the following class</p>
		<p>public class Ombersley{</p>
		<p>public static void main(String argv[]){</p>
		<p>boolean b1 = true;</p>
		<p>if((b1 ==true) || place(true)){</p>
		<p>System.out.println("Hello Crowle");</p>
		<p>}</p>
		<p>}</p>
		<p>public static boolean place(boolean location){</p>
		<p>if(location==true){</p>
		<p>System.out.println("Borcetshire");</p>
		<p>}</p>
		<p>System.out.println("Powick");</p>
		<p>return true;</p>
		<p>}</p>
		<p>}</p>
		<p>What will happen when you attempt to compile and run it?</p>
		<p>1) Compile time error</p>
		<p>2) Output of "Hello Crowle"</p>
		<p>3) Output of Borcetshire and Powick followed by "Hello Crowle"</p>
		<p>4) No output<br />________________________________________</p>
		<p>1) d.super().super().move();</p>
		<p>2) d.parent().parent().move();</p>
		<p>3) d.move();<br />4) none of the above;<br />________________________________________</p>
		<p>Question 29)Which of the following most closely describes the process of overriding?</p>
		<p>1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy</p>
		<p>2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy</p>
		<p>3) A method with the same name but different parameters gives multiple uses for the same method name</p>
		<p>4) A class is prevented from accessing methods in its immediate ancestor<br />________________________________________</p>
		<p>Question 30)Which of the following statements are true?</p>
		<p>1) The % is used to calculate a percentage thus: 10 % 20=50</p>
		<p>2) The / operator is used to divide one value by another</p>
		<p>3) The # symbol may not be used as the first character of a variable</p>
		<p>4) The $ symbol may not be used as the first character of a variable<br />________________________________________</p>
		<p>Question 31)Which of the following statements are true?</p>
		<p>1) The default layout manager for an Applet is FlowLayout</p>
		<p>2) The default layout manager for a Frame is FlowLayout</p>
		<p>3) A layout manager must be assigned to an Applet before the setSize method is called</p>
		<p>4) The FlowLayout manager attempts to honor the preferred size of any components<br />________________________________________</p>
		<p>Question 32)Which of the following statements are true about a variable created with the static modifier?</p>
		<p>1) Once assigned the value of a static variable may not be altered</p>
		<p>2) A static variable created in a method will keep the same value between calls</p>
		<p>3) Only one instance of a static variable will exist for any amount of class instances</p>
		<p>4) The static modifier can only be applied to a primitive value<br />________________________________________</p>
		<p>Question 33)Which of the following statements are true?</p>
		<p>1) Java uses a system called UTF for I/O to support international character sets</p>
		<p>2) The RandomAccessFile is the most suitable class for supporting international character sets</p>
		<p>3) An instance of FileInputStream may not be chained to an instance of FileOutputStream</p>
		<p>4) File I/O activities requires use of Exception handling<br />________________________________________</p>
		<p>Question 34)What will happen when you attempt to compile and run the following code?</p>
		<p>import java.io.*;</p>
		<p>class ExBase{</p>
		<p>abstract public void martley(){}</p>
		<p>}</p>
		<p>public class MyEx extends ExBase{</p>
		<p>public static void main(String argv[]){</p>
		<p>DataInputStream fi = new DataInputStream(System.in);</p>
		<p>try{</p>
		<p>fi.readChar();</p>
		<p>}catch(IOException e){</p>
		<p>System.exit(0);</p>
		<p>}finally {</p>
		<p>System.out.println("Doing finally");</p>
		<p>}</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile time error</p>
		<p>2) It will run, wait for a key press and then exit</p>
		<p>3) It will run, wait for a keypress, print "Doing finally" then exit</p>
		<p>4) At run and immediately exit<br />________________________________________</p>
		<p>Question 35)What will happen when you attempt to compile and run the following code</p>
		<p>public class Borley extends Thread{</p>
		<p>public static void main(String argv[]){</p>
		<p>Borley b = new Borley();</p>
		<p>b.start();</p>
		<p>}</p>
		<p>public void run(){<br />System.out.println("Running");</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compilation and run but no output</p>
		<p>2) Compilation and run with the output "Running"</p>
		<p>3) Compile time error with complaint of no Thread target</p>
		<p>4) Compile time error with complaint of no access to Thread package<br />________________________________________</p>
		<p>Question 36)Assuming any exception handling has been set up, which of the following will create an instance of the RandomAccessFile class</p>
		<p>1) RandomAccessFile raf=new RandomAccessFile("myfile.txt","rw");</p>
		<p>2) RandomAccessFile raf=new RandomAccessFile( new DataInputStream());</p>
		<p>3) RandomAccessFile raf=new RandomAccessFile("myfile.txt");</p>
		<p>4) RandomAccessFile raf=new RandomAccessFile( new File("myfile.txt"));<br />________________________________________</p>
		<p>Question 37)Given the following class definition</p>
		<p>public class Upton{</p>
		<p>public static void main(String argv[]){}</p>
		<p>public void amethod(int i){}//Here</p>
		<p>}</p>
		<p>Which of the following would be legal to place after the comment //Here ?</p>
		<p>1) public int amethod(int z){}</p>
		<p>2) public int amethod(int i,int j){return 99;}</p>
		<p>3) protected void amethod(long l){ }</p>
		<p>4) private void anothermethod(){}<br />________________________________________</p>
		<p>Question 38)Which of the following statements are true?</p>
		<p>1) Code must be written if the programmer wants a frame to close on selecting the system close menu</p>
		<p>2) The default layout for a Frame is the BorderLayout Manager</p>
		<p>3) The layout manager for a Frame cannot be changed once it has been assigned</p>
		<p>4) The GridBagLayout manager makes extensive use of the the GridBagConstraints class.<br />________________________________________</p>
		<p>Question 39)Given the following class definition</p>
		<p>public class Droitwich{</p>
		<p>class one{</p>
		<p>private class two{</p>
		<p>public void main(){</p>
		<p>System.out.println("two");</p>
		<p>}</p>
		<p>}</p>
		<p>}</p>
		<p>}</p>
		<p>Which of the following statements are true</p>
		<p>1) The code will not compile because the classes are nested to more than one level</p>
		<p>2) The code will not compile because class two is marked as private</p>
		<p>3) The code will compile and output the string two at runtime</p>
		<p>4) The code will compile without error<br />________________________________________</p>
		<p>Question 40)Given the following code</p>
		<p>class Base{</p>
		<p>static int oak=99;</p>
		<p>}public class Doverdale extends Base{</p>
		<p>public static void main(String argv[]){</p>
		<p>Doverdale d = new Doverdale();</p>
		<p>d.amethod();</p>
		<p>}public void amethod(){//Here}<br />     <br />}<br />Which of the following if placed after the comment //Here, will compile and modify the value of the variable oak?</p>
		<p>1) super.oak=1;</p>
		<p>2) oak=33;</p>
		<p>3) Base.oak=22;</p>
		<p>4) oak=50.1;<br />________________________________________</p>
		<p>Question 41)You are creating an application that has a form with a text entry field used to enter a persons age. Which of the following is appropriate for capturing this information.</p>
		<p>1) Use the Text field of a TextField and parse the result using Integer</p>
		<p>2) Use the getInteger method of the TextField</p>
		<p>3) Use the getText method of a TextBox and parse the result using the getInt method of Integer class</p>
		<p>4) Use the getText method of a TextField and use the parseInt method of the Integer class<br />________________________________________</p>
		<p>Question 42)Given the following declaration</p>
		<p>Integer i=new Integer(99);</p>
		<p>How can you now set the value of i to 10?</p>
		<p>1) i=10;</p>
		<p>2) i.setValue(10);</p>
		<p>3) i.parseInt(10);</p>
		<p>4) none of the above<br />________________________________________</p>
		<p>Question 43)Which of the following statements are true</p>
		<p>1) constructors cannot be overloaded</p>
		<p>2) constructors cannot be overridden</p>
		<p>3) a constructor can return a primitive or an object reference</p>
		<p>4) constructor code executes from the current class up the hierarchy to the ancestor class<br />________________________________________</p>
		<p>Question 44)Given a reference called<br />t</p>
		<p>to a class which extends Thread, which of the following will cause it to give up cycles to allow another thread to execute.</p>
		<p>1) t.yield();</p>
		<p>2) Thread.yield();</p>
		<p>3) yield(100); //Or some other suitable amount in milliseconds</p>
		<p>4) yield(t);<br />________________________________________</p>
		<p>Question 45)What will happen when you attempt to compile and run the following code?</p>
		<p>public class Sandys{</p>
		<p>private int court;</p>
		<p>public static void main(String argv[]){</p>
		<p>Sandys s = new Sandys(99);</p>
		<p>System.out.println(s.court);</p>
		<p>}</p>
		<p>Sandys(int ballcount){</p>
		<p>court=ballcount;</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile time error, the variable court is defined as private</p>
		<p>2) Compile time error, s is not initialized when the System.out method is called</p>
		<p>3) Compilation and execution with no output</p>
		<p>4) Compilation and run with an output of 99<br />________________________________________</p>
		<p>Question 46)Which of the following statements are true?</p>
		<p>1) A method cannot be overloaded to be less public in a child class</p>
		<p>2) To be overridden a method only needs the same name and parameter types</p>
		<p>3) To be overridden a method must have the same name, parameter and return types</p>
		<p>4) An overridden method must have the same name, parameter names and parameter types<br />________________________________________</p>
		<p>Question 47)What will happen when you attempt to compile and run the following code?</p>
		<p>class Base{</p>
		<p>Base(){</p>
		<p>System.out.println("Base");</p>
		<p>}<br />}public class Checket extends Base{</p>
		<p>public static void main(String argv[]){</p>
		<p>Checket c = new Checket();super();</p>
		<p>}</p>
		<p>Checket(){</p>
		<p>System.out.println("Checket");  </p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile time error</p>
		<p>2) Checket followed by Base</p>
		<p>3) Base followed by Checket</p>
		<p>4) runtime error<br />________________________________________</p>
		<p>Question 48)Which of the following statements are true?</p>
		<p>1) Static methods cannot be overriden to be non static</p>
		<p>2) Static methods cannot be declared as private</p>
		<p>3) Private methods cannot be overloaded</p>
		<p>4) An overloaded method cannot throw exceptions not checked in the base class<br />________________________________________</p>
		<p>Question 49)Which of the following statements are true?</p>
		<p>1) The automatic garbage collection of the JVM prevents programs from ever running out of memory</p>
		<p>2) A program can suggest that garbage collection be performed but not force it</p>
		<p>3) Garbage collection is platform independent</p>
		<p>4) An object becomes eligible for garbage collection when all references denoting it are set to null.<br />________________________________________</p>
		<p>Question 50)Given the following code</p>
		<p>public class Sytch{</p>
		<p>int x=2000;</p>
		<p>public static void main(String argv[]){</p>
		<p>System.out.println("Ms "+argv[1]+"Please pay $"+x);</p>
		<p>}</p>
		<p>}</p>
		<p>What will happen if you attempt to compile and run this code with the command line </p>
		<p>java Sytch Jones Diggle</p>
		<p>1) Compilation and output of Ms Diggle Please pay $2000</p>
		<p>2) Compile time error</p>
		<p>3) Compilation and output of Ms Jones Please pay $2000</p>
		<p>4) Compilation but runtime error<br />________________________________________</p>
		<p>Question 51)What will happen when you attempt to compile and run the following code</p>
		<p>class Base{</p>
		<p>protected int i = 99;</p>
		<p>}</p>
		<p>public class Ab{</p>
		<p>private int i=1;</p>
		<p>public static void main(String argv[]){</p>
		<p>Ab a = new Ab();</p>
		<p>a.hallow();</p>
		<p>}</p>
		<p>abstract void hallow(){</p>
		<p>System.out.println("Claines "+i);</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile time error</p>
		<p>2) Compilation and output of Claines 99</p>
		<p>3) Compilation and output of Claines 1</p>
		<p>4) Compilation and not output at runtime<br />________________________________________</p>
		<p>Question 52)You have been asked to create a scheduling system for a hotel and catering organsiation.</p>
		<p>You have been given the following information and asked to create a set of classes to represent it.</p>
		<p>On the catering side of the organsiation they have</p>
		<p>Head Chefs</p>
		<p>Chefs</p>
		<p>Apprentice Chefs</p>
		<p>The system needs to store an employeeid, salary and the holiday entitlement</p>
		<p>How would you best represent this information in Javae been given the following information and asked to create a set of classes to represent it.</p>
		<p>How would you best represent this information in Java</p>
		<p>1) Create classes for Head Chef, Chef, Apprentice Chef and store the other values in fields</p>
		<p>2) Create an employee class and derive sub classes for Head Chef, Chef, Apprentice Chef and store the other values in fields.</p>
		<p>3) Create and employee class with fields for Job title and fields for the other values.</p>
		<p>4) Create classes for all of the items mentioned and create a container class to represent employees</p>
		<p>1) new FileInputStream("file.name")</p>
		<p>2) new InputStreamReader(new FileInputStream("file.name"))</p>
		<p>3) new BufferedReader(new InputStreamReader(new FileInputStream("file.name")));</p>
		<p>4) new RandomAccessFile raf=new RandomAccessFile("myfile.txt","+rw");<br />________________________________________</p>
		<p>Question 54)What will happen when you attempt to compile and run the following code?</p>
		<p>public class Inc{</p>
		<p>public static void main(String argv[]){I</p>
		<p>nc inc = new Inc();</p>
		<p>int i =0;</p>
		<p>inc.fermin(i);</p>
		<p>i = i++;</p>
		<p>System.out.println(i);</p>
		<p>}void fermin(int i){</p>
		<p>i++;</p>
		<p>}</p>
		<p>}<br />1) Compile time error</p>
		<p>2) Output of 2</p>
		<p>3) Output of 1</p>
		<p>4) Output of 0<br />________________________________________</p>
		<p>Question 55)What will happen when you attempt to compile and run the following code?</p>
		<p>public class Agg{</p>
		<p>static public long i=10;</p>
		<p>public static void main(String argv[]){</p>
		<p>switch(i){</p>
		<p>default:System.out.println("no value given");</p>
		<p>case 1: System.out.println("one");</p>
		<p>case 10:System.out.println("ten");</p>
		<p>case 5:System.out.println("five");</p>
		<p>}</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile time error</p>
		<p>2) Output of "ten" followed by "five"</p>
		<p>3) Output of "ten"</p>
		<p>4) Compilation and run time error because of location of default<br />________________________________________</p>
		<p>Question 56)Given the following class</p>
		<p>public class ZeroPrint{</p>
		<p>public static void main(String argv[]){</p>
		<p>int i =0;//Here  </p>
		<p>}</p>
		<p>}</p>
		<p>Which of the following lines if placed after the comment //Here will print out 0.</p>
		<p>1) System.out.println(i++);</p>
		<p>2) System.out.println(i+'0');</p>
		<p>3) System.out.println(i);</p>
		<p>4) System.out.println(i--);<br />________________________________________</p>
		<p>Question 57)Given the following code</p>
		<p>1) System.out.println(a.getFields());</p>
		<p>2) System.out.println(a.name);</p>
		<p>3) System.out.println((Base) a.getFields());</p>
		<p>4) System.out.println( ((Agg) a).getFields());<br />________________________________________</p>
		<p>Question 58)What will happen when you attempt to compile and run the following code.</p>
		<p>public class Pvf{static boolean Paddy;</p>
		<p>public static void main(String argv[]){</p>
		<p>System.out.println(Paddy);</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile time error</p>
		<p>2) compilation and output of false</p>
		<p>3) compilation and output of true</p>
		<p>4) compilation and output of null<br />________________________________________</p>
		<p>Question 59)Which of the following statements are true?</p>
		<p>1) The x,y coordinates of an instance of MouseEvent can be obtained using the getX() and getY() methods</p>
		<p>2) The x,y coordinates of an instance of MouseEvent can be obtained using the X and Y integer fields</p>
		<p>3) The time of a MouseEvent can be extracted using the getTime() method</p>
		<p>4) The time of a MouseEvent can be extracted using the getWhen method<br />________________________________________</p>
		<p>Question 60)Given the following code </p>
		<p>import java.io.*;</p>
		<p>public class Ppvg{</p>
		<p>public static void main(String argv[]){</p>
		<p>Ppvg p = new Ppvg();</p>
		<p>p.fliton();}</p>
		<p>public int fliton(){</p>
		<p>try{</p>
		<p>FileInputStream din = new FileInputStream("Ppvg.java");</p>
		<p>din.read();</p>
		<p>}</p>
		<p>catch(IOException ioe){</p>
		<p>System.out.println("flytwick");       </p>
		<p>return 99;</p>
		<p>}</p>
		<p>finally{</p>
		<p>System.out.println("fliton");</p>
		<p>}</p>
		<p>return -1;</p>
		<p>}</p>
		<p>}</p>
		<p>Assuming the file Ppvg.java is available to be read which of the following statements are true if you try to compile and run the program?</p>
		<p>1) The program will run and output only "flytwick"</p>
		<p>2) The program will run and output only "fliton"</p>
		<p>3) The program will run and output both "fliton" and "flytwick"</p>
		<p>4) An error will occur at compile time because the method fliton attempts to return two values</p>
<img src ="http://www.blogjava.net/bily/aggbug/81727.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-17 11:30 <a href="http://www.blogjava.net/bily/articles/81727.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA题库格林模拟试题（二）</title><link>http://www.blogjava.net/bily/articles/81724.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Fri, 17 Nov 2006 03:16:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81724.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81724.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81724.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81724.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81724.html</trackback:ping><description><![CDATA[
		<p>Question 1)What will happen when you attempt to compile and run this code?</p>
		<p>abstract class Base{</p>
		<p>        abstract public void myfunc();</p>
		<p>        public void another(){</p>
		<p>        System.out.println("Another method");</p>
		<p>        }</p>
		<p>}</p>
		<p>public class Abs extends Base{</p>
		<p>        public static void main(String argv[]){</p>
		<p>        Abs a = new Abs();</p>
		<p>        a.amethod();</p>
		<p>        }</p>
		<p>        public void myfunc(){</p>
		<p>                System.out.println("My Func");</p>
		<p>                } </p>
		<p>        public void amethod(){</p>
		<p>        myfunc();      </p>
		<p>        }</p>
		<p>}</p>
		<p>1) The code will compile and run, printing out the words "My Func"</p>
		<p>2) The compiler will complain that the Base class has non abstract methods</p>
		<p>3) The code will compile but complain at run time that the Base class has non abstract methods</p>
		<p>4) The compiler will complain that the method myfunc in the base class has no body, nobody at all to looove it<br />________________________________________</p>
		<p>Question 2)What will happen when you attempt to compile and run this code?</p>
		<p>public class MyMain{</p>
		<p>public static void main(String argv){</p>
		<p>        System.out.println("Hello cruel world");</p>
		<p>        }</p>
		<p>}</p>
		<p>1) The compiler will complain that main is a reserved word and cannot be used for a class</p>
		<p>2) The code will compile and when run will print out "Hello cruel world"</p>
		<p>3) The code will compile but will complain at run time that no constructor is defined</p>
		<p>4) The code will compile but will complain at run time that main is not correctly defined<br />________________________________________</p>
		<p>Question 3)Which of the following are Java modifiers?</p>
		<p>1) public</p>
		<p>2) private</p>
		<p>3) friendly</p>
		<p>4) transient</p>
		<p>5) vagrant<br />________________________________________</p>
		<p>Question 4)What will happen when you attempt to compile and run this code?</p>
		<p>class Base{</p>
		<p>        abstract public void myfunc();</p>
		<p>        public void another(){</p>
		<p>        System.out.println("Another method");</p>
		<p>        }</p>
		<p>}</p>
		<p>public class Abs extends Base{</p>
		<p>        public static void main(String argv[]){</p>
		<p>        Abs a = new Abs();</p>
		<p>        a.amethod();</p>
		<p>        }</p>
		<p>        public void myfunc(){</p>
		<p>                System.out.println("My func");</p>
		<p>                } </p>
		<p>        public void amethod(){</p>
		<p>        myfunc();</p>
		<p>        }</p>
		<p>}</p>
		<p>1) The code will compile and run, printing out the words "My Func"</p>
		<p>2) The compiler will complain that the Base class is not declared as abstract.</p>
		<p>3) The code will compile but complain at run time that the Base class has non abstract methods</p>
		<p>4) The compiler will complain that the method myfunc in the base class has no body, nobody at all to looove it<br />________________________________________</p>
		<p>Question 5)Why might you define a method as native?</p>
		<p>1) To get to access hardware that Java does not know about</p>
		<p>2) To define a new data type such as an unsigned integer</p>
		<p>3) To write optimised code for performance in a language such as C/C++</p>
		<p>4) To overcome the limitation of the private scope of a method<br />________________________________________</p>
		<p>Question 6)What will happen when you attempt to compile and run this code?</p>
		<p>class Base{</p>
		<p>public final void amethod(){</p>
		<p>        System.out.println("amethod");</p>
		<p>        }</p>
		<p>}</p>
		<p>public class Fin extends Base{</p>
		<p>public static void main(String argv[]){</p>
		<p>        Base b = new Base();</p>
		<p>        b.amethod();</p>
		<p>        }</p>
		<p>}</p>
		<p>1) Compile time error indicating that a class with any final methods must be declared final itself</p>
		<p>2) Compile time error indicating that you cannot inherit from a class with final methods</p>
		<p>3) Run time error indicating that Base is not defined as final</p>
		<p>4) Success in compilation and output of "amethod" at run time.<br />________________________________________</p>
		<p>Question 7)What will happen when you attempt to compile and run this code?</p>
		<p>public class Mod{</p>
		<p>public static void main(String argv[]){</p>
		<p>    }</p>
		<p>        public static native void amethod();</p>
		<p>}</p>
		<p>1) Error at compilation: native method cannot be static</p>
		<p>2) Error at compilation native method must return value</p>
		<p>3) Compilation but error at run time unless you have made code containing native amethod available</p>
		<p>4) Compilation and execution without error<br />________________________________________</p>
		<p>Question 8)What will happen when you attempt to compile and run this code?</p>
		<p>private class Base{}</p>
		<p>public class Vis{</p>
		<p>transient int iVal;</p>
		<p>public static void main(String elephant[]){</p>
		<p>}</p>
		<p>}<br />1)Compile time error: Base cannot be private</p>
		<p>2)Compile time error indicating that an integer cannot be transient</p>
		<p>3)Compile time error transient not a data type</p>
		<p>4)Compile time error malformed main method<br />________________________________________</p>
		<p>Question 9)What happens when you attempt to compile and run these two files in the same directory?</p>
		<p>//File P1.java</p>
		<p>package MyPackage;</p>
		<p>class P1{</p>
		<p>void afancymethod(){</p>
		<p>        System.out.println("What a fancy method");</p>
		<p>        }</p>
		<p>}</p>
		<p>//File P2.java</p>
		<p>public class P2 extends P1{</p>
		<p>    public static void main(String argv[]){</p>
		<p> P2 p2 = new P2();</p>
		<p> p2.afancymethod();</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Both compile and P2 outputs "What a fancy method" when run</p>
		<p>2) Neither will compile</p>
		<p>3) Both compile but P2 has an error at run time</p>
		<p>4) P1 compiles cleanly but P2 has an error at compile time<br />________________________________________</p>
		<p>Question 10)You want to find out the value of the last element of an array. You write the following code. What will happen when you compile and run it.?</p>
		<p>public class MyAr{</p>
		<p>public static void main(String argv[]){</p>
		<p>        int[] i = new int[5];</p>
		<p>        System.out.println(i[5]);</p>
		<p>        }</p>
		<p>}</p>
		<p>1) An error at compile time</p>
		<p>2) An error at run time</p>
		<p>3) The value 0 will be output</p>
		<p>4) The string "null" will be output<br />________________________________________</p>
		<p>Question 11)You want to loop through an array and stop when you come to the last element. Being a good java programmer and forgetting everything you ever knew about C/C++ you know that arrays contain information about their size. Which of the following can you use?</p>
		<p>
				<br />1)myarray.length();</p>
		<p>2)myarray.length;</p>
		<p>3)myarray.size</p>
		<p>4)myarray.size();<br />________________________________________</p>
		<p>Question 12)What best describes the appearance of an application with the following code?</p>
		<p>import java.awt.*;</p>
		<p>public class FlowAp extends Frame{</p>
		<p>public static void main(String argv[]){</p>
		<p>    FlowAp fa=new FlowAp();</p>
		<p>    fa.setSize(400,300);</p>
		<p>    fa.setVisible(true);</p>
		<p>}</p>
		<p>FlowAp(){</p>
		<p>        add(new Button("One"));</p>
		<p>        add(new Button("Two"));</p>
		<p>        add(new Button("Three"));</p>
		<p>        add(new Button("Four"));</p>
		<p>    }//End of constructor</p>
		<p>}//End of Application</p>
		<p>1) A Frame with buttons marked One to Four placed on each edge.</p>
		<p>2) A Frame with buutons marked One to four running from the top to bottom</p>
		<p>3) A Frame with one large button marked Four in the Centre</p>
		<p>4) An Error at run time indicating you have not set a LayoutManager</p>
		<p>________________________________________</p>
		<p>Question 13)How do you indicate where a component will be positioned using Flowlayout?</p>
		<p>1) North, South,East,West</p>
		<p>2) Assign a row/column grid reference</p>
		<p>3) Pass a X/Y percentage parameter to the add method</p>
		<p>4) Do nothing, the FlowLayout will position the component<br />________________________________________</p>
		<p>Question 14)How do you change the current layout manager for a container</p>
		<p>1) Use the setLayout method</p>
		<p>2) Once created you cannot change the current layout manager of a component</p>
		<p>3) Use the setLayoutManager method</p>
		<p>4) Use the updateLayout method<br />________________________________________</p>
		<p>Question 15)Which of the following are fields of the GridBagConstraints class?</p>
		<p>1) ipadx</p>
		<p>2) fill</p>
		<p>3) insets</p>
		<p>4) width<br />________________________________________</p>
		<p>Question 16)What most closely matches the appearance when this code runs?</p>
		<p>import java.awt.*;</p>
		<p>public class CompLay extends Frame{</p>
		<p>public static void main(String argv[]){</p>
		<p>    CompLay cl = new CompLay();</p>
		<p>    }</p>
		<p>CompLay(){</p>
		<p>    Panel p = new Panel();</p>
		<p>    p.setBackground(Color.pink);</p>
		<p>    p.add(new Button("One"));</p>
		<p>    p.add(new Button("Two"));</p>
		<p>    p.add(new Button("Three"));</p>
		<p>    add("South",p);</p>
		<p>    setLayout(new FlowLayout());</p>
		<p>    setSize(300,300);</p>
		<p>    setVisible(true);</p>
		<p>    }</p>
		<p>}</p>
		<p>1) The buttons will run from left to right along the bottom of the Frame</p>
		<p>2) The buttons will run from left to right along the top of the frame</p>
		<p>3) The buttons will not be displayed</p>
		<p>4) Only button three will show occupying all of the frame<br />________________________________________</p>
		<p>Question 17)Which statements are correct about the anchor field?</p>
		<p>1) It is a field of the GridBagLayout manager for controlling component placement</p>
		<p>2) It is a field of the GridBagConstraints class for controlling component placement</p>
		<p>3) A valid setting for the anchor field is GridBagConstraints.NORTH</p>
		<p>4) The anchor field controls the height of components added to a container<br />________________________________________</p>
		<p>Question 18)What will happen when you attempt to compile and run the following code?</p>
		<p>public class Bground extends Thread{</p>
		<p>public static void main(String argv[]){</p>
		<p>                Bground b = new Bground();</p>
		<p>                b.run();</p>
		<p>        }</p>
		<p>        public void start(){</p>
		<p>                for (int i = 0; i &lt;10; i++){</p>
		<p>                        System.out.println("Value of i = " + i);</p>
		<p>                }</p>
		<p>        }</p>
		<p>}</p>
		<p>1) A compile time error indicating that no run method is defined for the Thread class</p>
		<p>2) A run time error indicating that no run method is defined for the Thread class</p>
		<p>3) Clean compile and at run time the values 0 to 9 are printed out</p>
		<p>4) Clean compile but no output at runtime<br />________________________________________</p>
		<p>Question 19)Is the following statement true or false?</p>
		<p>When using the GridBagLayout manager, each new component requires a new instance of the GridBagConstraints class.</p>
		<p>1) true</p>
		<p>2) false<br />________________________________________</p>
		<p>Question 20)Which most closely matches a description of a Java Map?</p>
		<p>1) A vector of arrays for a 2D geographic representation</p>
		<p>2) A class for containing unique array elements</p>
		<p>3) A class for containing unique vector elements</p>
		<p>4) An interface that ensures that implementing classes cannot contain duplicate keys<br />________________________________________</p>
		<p>Question 21)How does the set collection deal with duplicate elements?</p>
		<p>1) An exception is thrown if you attempt to add an element with a duplicate value</p>
		<p>2) The add method returns false if you attempt to add an element with a duplicate value</p>
		<p>3) A set may contain elements that return duplicate values from a call to the equals method</p>
		<p>4) Duplicate values will cause an error at compile time<br />________________________________________</p>
		<p>Question 22)What can cause a thread to stop executing?</p>
		<p>1) The program exits via a call to System.exit(0);</p>
		<p>2) Another thread is given a higher priority</p>
		<p>3) A call to the thread's stop method.</p>
		<p>4) A call to the halt method of the Thread class<br />________________________________________</p>
		<p>Question 23)For a class defined inside a method, what rule governs access to the variables of the enclosing method?</p>
		<p>1) The class can access any variable</p>
		<p>2) The class can only access static variables<br />3) The class can only access transient variables</p>
		<p>4) The class can only access final variables<br />________________________________________</p>
		<p>Question 24)Under what circumstances might you use the yield method of the Thread class</p>
		<p>1) To call from the currently running thread to allow another thread of the same or higher priority to run</p>
		<p>2) To call on a waiting thread to allow it to run</p>
		<p>3) To allow a thread of higher priority to run</p>
		<p>4) To call from the currently running thread with a parameter designating which thread should be allowed to run<br />________________________________________</p>
		<p>Question 25)What will happen when you attempt to compile and run the following code</p>
		<p>public class Hope{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Hope h = new Hope();</p>
		<p>    }</p>
		<p>    protected Hope(){</p>
		<p>for(int i =0; i &lt;10; i ++){</p>
		<p>     System.out.println(i);</p>
		<p> }</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Compilation error: Constructors cannot be declared protected</p>
		<p>2) Run time error: Constructors cannot be declared protected</p>
		<p>3) Compilation and running with output 0 to 10</p>
		<p>4) Compilation and running with output 0 to 9<br />________________________________________</p>
		<p>Question 26)What will happen when you attempt to compile and run the following code</p>
		<p>public class MySwitch{</p>
		<p>public static void main(String argv[]){</p>
		<p>    MySwitch ms= new MySwitch();</p>
		<p>ms.amethod();</p>
		<p>    }</p>
		<p>public void amethod(){</p>
		<p>int k=10; </p>
		<p>switch(k){ </p>
		<p>default: //Put the default at the bottom, not here</p>
		<p>System.out.println("This is the default output"); </p>
		<p>break; </p>
		<p>case 10: </p>
		<p>System.out.println("ten");</p>
		<p>case 20: </p>
		<p>System.out.println("twenty"); </p>
		<p>break; </p>
		<p>}</p>
		<p>}</p>
		<p>}</p>
		<p>1) None of these options</p>
		<p>2) Compile time error target of switch must be an integral type</p>
		<p>3) Compile and run with output "This is the default output"</p>
		<p>4) Compile and run with output of the single line "ten"<br />________________________________________</p>
		<p>Question 27)Which of the following is the correct syntax for suggesting that the JVM performs garbage collection</p>
		<p>1) System.free();</p>
		<p>2) System.setGarbageCollection();</p>
		<p>3) System.out.gc();</p>
		<p>4) System.gc();<br />________________________________________</p>
		<p>Question 28) What will happen when you attempt to compile and run the following code</p>
		<p>public class As{</p>
		<p>    int i = 10;</p>
		<p>    int j;</p>
		<p>    char z= 1;</p>
		<p>    boolean b;</p>
		<p>    public static void main(String argv[]){</p>
		<p> As a = new As();</p>
		<p> a.amethod();</p>
		<p>    }</p>
		<p>    public void amethod(){</p>
		<p>        System.out.println(j);</p>
		<p>        System.out.println(b);                </p>
		<p>    }</p>
		<p>}</p>
		<p>1) Compilation succeeds and at run time an output of 0 and false</p>
		<p>2) Compilation succeeds and at run time an output of 0 and true<br />3) Compile time error b is not initialised</p>
		<p>4) Compile time error z must be assigned a char value<br />________________________________________</p>
		<p>Question 29)What will happen when you attempt to compile and run the following code with the command line "hello there"</p>
		<p>public class Arg{</p>
		<p>String[] MyArg;</p>
		<p>        public static void main(String argv[]){</p>
		<p>        MyArg=argv;</p>
		<p>        }</p>
		<p>        public void amethod(){</p>
		<p>                System.out.println(argv[1]);</p>
		<p>        }</p>
		<p>}</p>
		<p>1) Compile time error</p>
		<p>2) Compilation and output of "hello"</p>
		<p>3) Compilation and output of "there"</p>
		<p>4) None of the above<br />________________________________________</p>
		<p>Question 30)What will happen when you attempt to compile and run the following code</p>
		<p>public class StrEq{</p>
		<p>public static void main(String argv[]){</p>
		<p>        StrEq s = new StrEq();</p>
		<p>        }</p>
		<p>        private StrEq(){</p>
		<p>                String s = "Marcus";</p>
		<p>                String s2 = new String("Marcus");</p>
		<p>                if(s == s2){</p>
		<p>                        System.out.println("we have a match");</p>
		<p>                        }else{</p>
		<p>                        System.out.println("Not equal");</p>
		<p>                }</p>
		<p>       }</p>
		<p>}</p>
		<p>1) Compile time error caused by private constructor</p>
		<p>2) Output of "we have a match"</p>
		<p>3) Output of "Not equal"</p>
		<p>4) Compile time error by attempting to compare strings using ==</p>
		<p>Question 31)What will happen when you attempt to compile and run the following code</p>
		<p>import java.io.*;</p>
		<p>class Base{</p>
		<p>    public void amethod()throws FileNotFoundException{}</p>
		<p>}</p>
		<p>public class ExcepDemo extends Base{</p>
		<p>    public static void main(String argv[]){</p>
		<p> ExcepDemo e = new ExcepDemo();</p>
		<p>    }</p>
		<p>    public void amethod(){}</p>
		<p>    protected ExcepDemo(){</p>
		<p> try{</p>
		<p>     DataInputStream din = new DataInputStream(System.in);</p>
		<p>     System.out.println("Pausing");</p>
		<p>     din.readByte();</p>
		<p>     System.out.println("Continuing");</p>
		<p>     this.amethod();</p>
		<p> }catch(IOException ioe) {}</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Compile time error caused by protected constructor</p>
		<p>2) Compile time error caused by amethod not declaring Exception</p>
		<p>3) Runtime error caused by amethod not declaring Exception</p>
		<p>4) Compile and run with output of "Pausing" and "Continuing" after a key is hit<br />________________________________________</p>
		<p>Question 32)What will happen when you attempt to compile and run this program</p>
		<p>public class Outer{</p>
		<p>public String name = "Outer";</p>
		<p>
				<br />public static void main(String argv[]){</p>
		<p>        Inner i = new Inner();</p>
		<p>        i.showName();</p>
		<p>    }//End of main</p>
		<p>        private class Inner{</p>
		<p>
				<br />        String name =new String("Inner");</p>
		<p>                void showName(){</p>
		<p>                        System.out.println(name);</p>
		<p>                }</p>
		<p>        }//End of Inner class<br />}<br />1) Compile and run with output of "Outer"</p>
		<p>2) Compile and run with output of "Inner"</p>
		<p>3) Compile time error because Inner is declared as private</p>
		<p>4) Compile time error because of the line creating the instance of Inner<br />________________________________________</p>
		<p>Question 33)What will happen when you attempt to compile and run this code</p>
		<p>//Demonstration of event handling</p>
		<p>import java.awt.*;</p>
		<p>import java.awt.event.*;</p>
		<p>public class MyWc extends Frame implements WindowListener{</p>
		<p>public static void main(String argv[]){</p>
		<p>        MyWc mwc = new MyWc();</p>
		<p>        }</p>
		<p>        public void windowClosing(WindowEvent we){</p>
		<p>                System.exit(0);</p>
		<p>                }//End of windowClosing</p>
		<p>      public void  MyWc(){</p>
		<p>        setSize(300,300);</p>
		<p>        setVisible(true);</p>
		<p>        }</p>
		<p>}//End of class</p>
		<p>1) Error at compile time</p>
		<p>2) Visible Frame created that that can be closed</p>
		<p>3) Compilation but no output at run time</p>
		<p>4) Error at compile time because of comment before import statements<br />________________________________________</p>
		<p>Question 34)Which option most fully describes will happen when you attempt to compile and run the following code</p>
		<p>public class MyAr{</p>
		<p>    public static void main(String argv[]) {</p>
		<p>        MyAr m = new MyAr();</p>
		<p>        m.amethod();</p>
		<p>    }</p>
		<p>    public void amethod(){</p>
		<p>static int i;</p>
		<p>System.out.println(i);</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compilation and output of the value 0</p>
		<p>2) Compile time error because i has not been initialized</p>
		<p>3) Compilation and output of null</p>
		<p>4) Compile time error <br />________________________________________</p>
		<p>Question 35)Which of the following will compile correctly</p>
		<p>1) short myshort = 99S;</p>
		<p>2) String name = 'Excellent tutorial Mr Green';</p>
		<p>3) char c = 17c;</p>
		<p>4)int z = 015; <br />________________________________________</p>
		<p>Question 36)Which of the following are Java key words</p>
		<p>1)double</p>
		<p>2)Switch</p>
		<p>3)then</p>
		<p>4)instanceof<br />________________________________________</p>
		<p>Question 37)What will be output by the following line?</p>
		<p>System.out.println(Math.floor(-2.1));</p>
		<p>1) -2</p>
		<p>2) 2.0</p>
		<p>3) -3</p>
		<p>4) -3.0<br />________________________________________</p>
		<p>Question 38)Given the following main method in a class called Cycle and a command line of</p>
		<p>java Cycle one two</p>
		<p>what will be output?</p>
		<p>public static void main(String bicycle[]){</p>
		<p>        System.out.println(bicycle[0]);<br />}</p>
		<p>1) None of these options</p>
		<p>2) cycle</p>
		<p>3) one</p>
		<p>4) two<br />________________________________________</p>
		<p>Question 39)Which of the following statements are true?</p>
		<p>1) At the root of the collection hierarchy is a class called Collection</p>
		<p>2) The collection interface contains a method called enumerator</p>
		<p>3) The interator method returns an instance of the Vector class</p>
		<p>4) The Set interface is designed for unique elements<br />________________________________________</p>
		<p>Question 40)Which of the following statements are correct?</p>
		<p>1) If multiple listeners are added to a component only events for the last listener added will be processed</p>
		<p>2) If multiple listeners are added to a component the events will be processed for all but with no guarantee in the order</p>
		<p>3) Adding multiple listeners to a comnponent will cause a compile time error</p>
		<p>4) You may remove as well add listeners to a component.<br />________________________________________</p>
		<p>Question 41)Given the following code</p>
		<p>class Base{}</p>
		<p>public class MyCast extends Base{</p>
		<p>    static boolean b1=false;</p>
		<p>    static int i = -1;</p>
		<p>    static double d = 10.1;</p>
		<p>    public static void main(String argv[]){</p>
		<p>        MyCast m = new MyCast();</p>
		<p>        Base b = new Base();</p>
		<p>        //Here</p>
		<p>    }</p>
		<p>}</p>
		<p>Which of the following, if inserted at the comment //Here will allow the code to compile and run without error</p>
		<p>1) b=m;</p>
		<p>2) m=b;</p>
		<p>3) d =i;</p>
		<p>4) b1 =i;<br />________________________________________</p>
		<p>Question 42)Which of the following statements about threading are true</p>
		<p>1) You can only obtain a mutually exclusive lock on methods in a class that extends Thread or implements runnable</p>
		<p>2) You can obtain a mutually exclusive lock on any object</p>
		<p>3) A thread can obtain a mutually exclusive lock on an object by calling a synchronized method on that object.</p>
		<p>4) Thread scheduling algorithms are platform dependent<br />________________________________________</p>
		<p>Question 43)Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC.<br />The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?</p>
		<p>1) Give the goahead for further design using the current scheme</p>
		<p>2) Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type</p>
		<p>3) Ask for the option of WindowsPC to be removed as it will soon be obsolete</p>
		<p>4) Change the hierarchy to remove the need for the superfluous Computer Class.<br />Question 44)Which of the following statements are true</p>
		<p>1) An inner class may be defined as static</p>
		<p>2) There are NO circumstances where an inner class may be defined as private</p>
		<p>3) A programmer may only provide one constructor for an anonymous class</p>
		<p>4) An inner class may extend another class<br />________________________________________</p>
		<p>Question 45)What will happen when you attempt to compile and run the following code</p>
		<p>int Output=10;</p>
		<p>boolean b1 = false;</p>
		<p>if((b1==true) &amp;&amp; ((Output+=10)==20)){</p>
		<p>    System.out.println("We are equal "+Output);</p>
		<p>    }else</p>
		<p>    {</p>
		<p>System.out.println("Not equal! "+Output);</p>
		<p>}</p>
		<p>1) Compile error, attempting to peform binary comparison on logical data type</p>
		<p>2) Compilation and output of "We are equal 10"</p>
		<p>3) Compilation and output of "Not equal! 20"</p>
		<p>4) Compilation and output of "Not equal! 10"<br />________________________________________</p>
		<p>Question 46)Given the following variables which of the following lines will compile without error?</p>
		<p>String s = "Hello";</p>
		<p>long l = 99;</p>
		<p>double d = 1.11;</p>
		<p>int i = 1;</p>
		<p>int j = 0;</p>
		<p>1) j= i &lt;&lt;S;</p>
		<p>2) j= i&lt;&lt;J;</p>
		<p>3) j=i&lt;&lt;D;</p>
		<p>4)j=i&lt;&lt;L;</p>
		<p>________________________________________</p>
		<p>Question 47)What will be output by the following line of code?</p>
		<p>System.out.println(010|4);</p>
		<p>1) 14</p>
		<p>2) 0</p>
		<p>3) 6</p>
		<p>4) 12</p>
		<p>________________________________________</p>
		<p>Question 48)Given the following variables</p>
		<p>char c = 'c';</p>
		<p>int i = 10;</p>
		<p>double d = 10;</p>
		<p>long l = 1;</p>
		<p>String s = "Hello";</p>
		<p>Which of the following will compile without error?</p>
		<p>1)c=c+i;</p>
		<p>2)s+=i;</p>
		<p>3)i+=s;</p>
		<p>4)c+=s;<br />________________________________________</p>
		<p>Question 49)Which of the following will compile without error?</p>
		<p>1) File f = new File("/","autoexec.bat");</p>
		<p>2) DataInputStream d = new DataInputStream(System.in);</p>
		<p>3) OutputStreamWriter o = new OutputStreamWriter(System.out);</p>
		<p>4) RandomAccessFile r = new RandomAccessFile("OutFile");<br />________________________________________</p>
		<p>Question 50)Given the folowing classes which of the following will compile without error?</p>
		<p>interface IFace{}</p>
		<p>class CFace implements IFace{}</p>
		<p>class Base{}</p>
		<p>public class ObRef extends Base{</p>
		<p>    public static void main(String argv[]){</p>
		<p>        ObRef ob = new ObRef();</p>
		<p>        Base b = new Base();</p>
		<p>        Object o1 = new Object();</p>
		<p>        IFace o2 = new CFace();</p>
		<p>}</p>
		<p>}<br />1)o1=o2;</p>
		<p>2)b=ob;</p>
		<p>3)ob=b;</p>
		<p>4)o1=b;<br />________________________________________</p>
		<p>Question 51)Given the following code what will be the output?</p>
		<p>class ValHold{</p>
		<p>        public int i = 10;</p>
		<p>}</p>
		<p>public class ObParm{</p>
		<p>public static void main(String argv[]){</p>
		<p>        ObParm o = new ObParm();</p>
		<p>        o.amethod();</p>
		<p>        }</p>
		<p>        public void amethod(){</p>
		<p>                int i = 99;</p>
		<p>                ValHold v = new ValHold();</p>
		<p>                v.i=30;</p>
		<p>                another(v,i);</p>
		<p>                System.out.print( v.i );</p>
		<p>        }//End of amethod</p>
		<p>        public void another(ValHold v, int i){</p>
		<p>                i=0;</p>
		<p>                v.i = 20;</p>
		<p>                ValHold vh = new ValHold();</p>
		<p>                v =  vh;</p>
		<p>                System.out.print(v.i);</p>
		<p>        System.out.print(i);</p>
		<p>        }//End of another</p>
		<p>}</p>
		<p>1) 10030</p>
		<p>2) 20030</p>
		<p>3) 209930</p>
		<p>4) 10020</p>
		<p>________________________________________</p>
		<p>Question 52)Given the following class definition, which of the following methods could be legally placed after the comment</p>
		<p>//Here </p>
		<p>
				<br />public class Rid{</p>
		<p>        public void amethod(int i, String s){}</p>
		<p>        //Here</p>
		<p>}</p>
		<p>1)public void amethod(String s, int i){}</p>
		<p>2)public int amethod(int i, String s){}</p>
		<p>3)public void amethod(int i, String mystring){}</p>
		<p>4) public void Amethod(int i, String s) {}<br />________________________________________</p>
		<p>Question 53)Given the following class definition which of the following can be legally placed after the comment line</p>
		<p>//Here ?</p>
		<p>class Base{</p>
		<p>public Base(int i){}</p>
		<p>}</p>
		<p>public class MyOver extends Base{</p>
		<p>public static void main(String arg[]){</p>
		<p>                MyOver m = new MyOver(10);</p>
		<p>                }</p>
		<p>        MyOver(int i){</p>
		<p>                super(i);</p>
		<p>        }</p>
		<p>        MyOver(String s, int i){</p>
		<p>                this(i);</p>
		<p>                 //Here</p>
		<p>        }</p>
		<p>}</p>
		<p>1)MyOver m = new MyOver();</p>
		<p>2)super();</p>
		<p>3)this("Hello",10);</p>
		<p>4)Base b = new Base(10);<br />________________________________________</p>
		<p>Question 54)Given the following class definition, which of the following statements would be legal after the comment //Here</p>
		<p>class InOut{</p>
		<p>String s= new String("Between");</p>
		<p>        public void amethod(final int iArgs){</p>
		<p>       int iam;</p>
		<p>              class Bicycle{</p>
		<p>                       public void sayHello(){</p>
		<p>                        //Here</p>
		<p>                        }</p>
		<p>                }//End of bicycle class</p>
		<p>        }//End of amethod</p>
		<p>       public void another(){</p>
		<p>       int iOther;</p>
		<p>       }</p>
		<p>}</p>
		<p>1) System.out.println(s);</p>
		<p>2) System.out.println(iOther);</p>
		<p>3) System.out.println(iam);</p>
		<p>4) System.out.println(iArgs);</p>
		<p>________________________________________</p>
		<p>Question 55)Which of the following are methods of the Thread class?</p>
		<p>1) yield()</p>
		<p>2) sleep(long msec)</p>
		<p>3) go()</p>
		<p>4) stop()<br />________________________________________</p>
		<p>Question 56)Which of the following methods are members of the Vector class and allow you to input a new element</p>
		<p>1) addElement</p>
		<p>2) insert</p>
		<p>3) append</p>
		<p>4) addItem<br />________________________________________</p>
		<p>Question 57)Which of the following statements are true?</p>
		<p>1) Adding more classes via import statements will cause a performance overhead, only import classes you actually use.</p>
		<p>2) Under no circumstances can a class be defined with the private modifier</p>
		<p>3) A inner class may under some circumstances be defined with the protected modifier</p>
		<p>4) An interface cannot be instantiated<br />________________________________________</p>
		<p>Question 58)Which of the following are correct event handling methods</p>
		<p>1) mousePressed(MouseEvent e){}</p>
		<p>2) MousePressed(MouseClick e){}</p>
		<p>3) functionKey(KeyPress k){}</p>
		<p>4) componentAdded(ContainerEvent e){}<br />________________________________________</p>
		<p>Question 59)Which of the following are methods of the Collection interface?</p>
		<p>1) iterator</p>
		<p>2) isEmpty</p>
		<p>3) toArray</p>
		<p>4) setText<br />________________________________________</p>
		<p>Question 60)Which of the following best describes the use of the synchronized keyword?</p>
		<p>1) Allows two process to run in paralell but to communicate with each other</p>
		<p>2) Ensures only one thread at a time may access a method or object</p>
		<p>3) Ensures that two or more processes will start and end at the same time</p>
		<p>4) Ensures that two or more Threads will start and end at the same time<br /></p>
<img src ="http://www.blogjava.net/bily/aggbug/81724.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-17 11:16 <a href="http://www.blogjava.net/bily/articles/81724.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA题库格林模拟试题（一）</title><link>http://www.blogjava.net/bily/articles/81630.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 13:42:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81630.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81630.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81630.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81630.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81630.html</trackback:ping><description><![CDATA[
		<p>JAVA题库:格林模拟试题一<br />Question 1)Which of the following lines will compile without warning or error. </p>
		<p>1) float f=1.3; </p>
		<p>2) char c="a"; </p>
		<p>3) byte b=257; </p>
		<p>4) boolean b=null; </p>
		<p>5) int i=10; </p>
		<p>
				<br />Question 2)What will happen if you try to compile and run the following code </p>
		<p>public class MyClass {</p>
		<p>    public static void main(String arguments[]) {</p>
		<p> amethod(arguments);</p>
		<p>    }</p>
		<p>    public void amethod(String[] arguments) {</p>
		<p> System.out.println(arguments);</p>
		<p> System.out.println(arguments[1]);</p>
		<p>    }</p>
		<p>}</p>
		<p>1) error Can't make static reference to void amethod. </p>
		<p>2) error method main not correct </p>
		<p>3) error array must include parameter </p>
		<p>4) amethod must be declared with String</p>
		<p>
				<br />Question 3)Which of the following will compile without error </p>
		<p>1) <br />import java.awt.*;</p>
		<p>package Mypackage;</p>
		<p>class Myclass {}</p>
		<p>2) <br />package MyPackage;</p>
		<p>
				<br />import java.awt.*;</p>
		<p>
				<br />class MyClass{}</p>
		<p>3) <br />/*This is a comment */</p>
		<p>package MyPackage;</p>
		<p>import java.awt.*;</p>
		<p>class MyClass{}</p>
		<p>
				<br />Question 4)A byte can be of what size </p>
		<p>1) -128 to 127 </p>
		<p>2) (-2 power 8 )-1 to 2 power 8 </p>
		<p>3) -255 to 256 </p>
		<p>4)depends on the particular implementation of the Java Virtual machine </p>
		<p>
				<br />Question 5)What will be printed out if this code is run with the following command line? </p>
		<p>java myprog good morning</p>
		<p>public class myprog{public static void main(String argv[]){System.out.println(argv[2]);}<br />}</p>
		<p>1) myprog</p>
		<p>2) good </p>
		<p>3) morning </p>
		<p>4) Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2" </p>
		<p>
				<br />Question 6)Which of the following are keywords or reserved words in Java? </p>
		<p>1) if </p>
		<p>2) then </p>
		<p>3) goto </p>
		<p>4) while </p>
		<p>5) case </p>
		<p>
				<br />Question 7)Which of the following are legal identifiers </p>
		<p>1) 2variable </p>
		<p>2) variable2 </p>
		<p>3) _whatavariable </p>
		<p>4) _3_ </p>
		<p>5) $anothervar </p>
		<p>6) #myvar </p>
		<p>
				<br />Question 8)What will happen when you compile and run the following code? </p>
		<p>public class MyClass{</p>
		<p> static int i;</p>
		<p> public static void main(String argv[]){</p>
		<p> System.out.println(i);</p>
		<p> }</p>
		<p>}</p>
		<p>1) Error Variable i may not have been initialized </p>
		<p>2) null </p>
		<p>3) 1 </p>
		<p>4) 0 </p>
		<p>
				<br />Question 9)What will happen if you try to compile and run the following code? </p>
		<p>public class Q {</p>
		<p> public static void main(String argv[]){</p>
		<p> int anar[]=new int[]{1,2,3};</p>
		<p> System.out.println(anar[1]);</p>
		<p> }</p>
		<p>}</p>
		<p>1) 1 </p>
		<p>2) Error anar is referenced before it is initialized </p>
		<p>3) 2 </p>
		<p>4) Error: size of array must be defined </p>
		<p>
				<br />Question 10)What will happen if you try to compile and run the following code? </p>
		<p>public class Q {</p>
		<p> public static void main(String argv[]){</p>
		<p> int anar[]=new int[5];</p>
		<p> System.out.println(anar[0]);</p>
		<p> }</p>
		<p>}</p>
		<p>1) Error: anar is referenced before it is initialized </p>
		<p>2) null </p>
		<p>3) 0 </p>
		<p>4) 5 </p>
		<p>
				<br />Question 11)What will be the result of attempting to compile and run the following code? </p>
		<p>abstract class MineBase {</p>
		<p>abstract void amethod();</p>
		<p>static int i;</p>
		<p>}</p>
		<p>public class Mine extends MineBase {</p>
		<p>public static void main(String argv[]){</p>
		<p>int[] ar=new int[5];</p>
		<p>for(i=0;i &lt; ar.length;i++)</p>
		<p>System.out.println(ar[i]);</p>
		<p>}</p>
		<p>}</p>
		<p>1) a sequence of 5 0's will be printed </p>
		<p>2) Error: ar is used before it is initialized </p>
		<p>3) Error Mine must be declared abstract </p>
		<p>4) IndexOutOfBoundes Error </p>
		<p>
				<br />Question 12)What will be printed out if you attempt to compile and run the following code ?<br /> <br />int i=1;</p>
		<p> switch (i) {</p>
		<p> case 0:</p>
		<p> System.out.println("zero");</p>
		<p> break;</p>
		<p> case 1:</p>
		<p> System.out.println("one");</p>
		<p> case 2:</p>
		<p> System.out.println("two");</p>
		<p> default:</p>
		<p> System.out.println("default");</p>
		<p> }</p>
		<p>1) one </p>
		<p>2) one, default </p>
		<p>3) one, two, default </p>
		<p>4) default </p>
		<p>
				<br />Question 13)What will be printed out if you attempt to compile and run the following code? </p>
		<p>int i=9;</p>
		<p>switch (i) {</p>
		<p> default:</p>
		<p> System.out.println("default");</p>
		<p> case 0:</p>
		<p> System.out.println("zero");</p>
		<p> break;</p>
		<p> case 1:</p>
		<p> System.out.println("one");</p>
		<p> case 2:</p>
		<p> System.out.println("two");</p>
		<p>}</p>
		<p>1) default </p>
		<p>2) default, zero </p>
		<p>3) error default clause not defined </p>
		<p>4) no output displayed</p>
		<p>
				<br />Question 14)Which of the following lines of code will compile without error </p>
		<p>1) <br />int i=0;</p>
		<p>if(i) {</p>
		<p> System.out.println("Hello");</p>
		<p> }</p>
		<p>2)<br /> <br />boolean b=true;</p>
		<p>boolean b2=true;</p>
		<p>if(b==b2) {</p>
		<p>System.out.println("So true");</p>
		<p>}</p>
		<p>3) </p>
		<p>int i=1;</p>
		<p>int j=2;</p>
		<p>if(i==1|| j==2)</p>
		<p>System.out.println("OK");</p>
		<p>4) </p>
		<p>int i=1;</p>
		<p>int j=2;</p>
		<p>if(i==1 &amp;| j==2)</p>
		<p>System.out.println("OK");</p>
		<p>
				<br />Question 15)What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory?. </p>
		<p>import java.io.*;</p>
		<p>public class Mine {</p>
		<p>    public static void main(String argv[]){</p>
		<p> Mine m=new Mine();</p>
		<p> System.out.println(m.amethod());</p>
		<p>    }</p>
		<p>    public int amethod() {</p>
		<p> try {</p>
		<p>     FileInputStream dis=new FileInputStream("Hello.txt");</p>
		<p> }catch (FileNotFoundException fne) {</p>
		<p>     System.out.println("No such file found");</p>
		<p>     return -1;</p>
		<p> }catch(IOException ioe) {</p>
		<p> } finally{</p>
		<p>     System.out.println("Doing finally");</p>
		<p> }</p>
		<p> return 0;</p>
		<p>    }</p>
		<p>}</p>
		<p>1) No such file found </p>
		<p>2 No such file found ,-1 </p>
		<p>3) No such file found, Doing finally, -1 </p>
		<p>4) 0 </p>
		<p>
				<br />Question 16)Which of the following statements are true? </p>
		<p>1) Methods cannot be overriden to be more private</p>
		<p>2) static methods cannot be overloaded</p>
		<p>3) private methods cannot be overloaded</p>
		<p>4) An overloaded method cannot throw exceptions not checked in the base class</p>
		<p>
				<br />Question 17)What will happen if you attempt to compile and run the following code? </p>
		<p>class Base {}</p>
		<p>class Sub extends Base {}</p>
		<p>class Sub2 extends Base {}</p>
		<p>public class CEx{</p>
		<p>public static void main(String argv[]){</p>
		<p>Base b=new Base();</p>
		<p>Sub s=(Sub) b;</p>
		<p>}</p>
		<p>}</p>
		<p>1) Compile and run without error </p>
		<p>2) Compile time Exception </p>
		<p>3) Runtime Exception </p>
		<p>
				<br />Question 18)Which of the following statements are true?</p>
		<p>1) System.out.println( -1 &gt;&gt;&gt; 2);will output a result larger than 10</p>
		<p>2) System.out.println( -1 &gt;&gt;&gt; 2); will output a positive number </p>
		<p>3) System.out.println( 2 &gt;&gt; 1); will output the number 1 </p>
		<p>4) System.out.println( 1 &lt;&lt;&lt; 2); will output the number </p>
		<p>
				<br />Question 19)What will happen when you attempt to compile and run the following code?</p>
		<p>public class Tux extends Thread{</p>
		<p>        static String sName = "vandeleur";</p>
		<p>        public static void main(String argv[]){</p>
		<p>        Tux t = new Tux();</p>
		<p>        t.piggy(sName);</p>
		<p>        System.out.println(sName);</p>
		<p>        }</p>
		<p>        public void piggy(String sName){</p>
		<p>                sName = sName + " wiggy";</p>
		<p>        start();</p>
		<p>        }</p>
		<p>        public void run(){</p>
		<p>        for(int i=0;i  &lt;  4; i++){</p>
		<p>                sName = sName + " " + i;</p>
		<p>        }</p>
		<p>        }</p>
		<p>}</p>
		<p>1) Compile time error</p>
		<p>2) Compilation and output of "vandeleur wiggy"</p>
		<p>3) Compilation and output of "vandeleur wiggy 0 1 2 3"</p>
		<p>4) Compilation and output of either "vandeleur", "vandeleur 0", "vandeleur 0 1" "vandaleur 0 1 2" or "vandaleur 0 1 2 3"</p>
		<p>
				<br />Question 20)What will be displayed when you attempt to compile and run the following code </p>
		<p>//Code start<br />import java.awt.*;</p>
		<p>public class Butt extends Frame{</p>
		<p>public static void main(String argv[]){</p>
		<p>Butt MyBut=new Butt();</p>
		<p>}</p>
		<p>Butt(){</p>
		<p>Button HelloBut=new Button("Hello");</p>
		<p>Button ByeBut=new Button("Bye");</p>
		<p>add(HelloBut);</p>
		<p>add(ByeBut);</p>
		<p>setSize(300,300);</p>
		<p>setVisible(true);</p>
		<p>}</p>
		<p>}</p>
		<p>//Code end<br />1) Two buttons side by side occupying all of the frame, Hello on the left and Bye on the right </p>
		<p>2) One button occupying the entire frame saying Hello </p>
		<p>3) One button occupying the entire frame saying Bye </p>
		<p>4) Two buttons at the top of the frame one saying Hello the other saying Bye </p>
		<p>
				<br />Question 21)What will be output by the following code? </p>
		<p>public class MyFor{</p>
		<p>    public static void main(String argv[]){</p>
		<p> int i;</p>
		<p> int j;</p>
		<p>    outer:</p>
		<p> for (i=1;i &lt;3;i++)</p>
		<p>     inner:</p>
		<p> for(j=1; j&lt;3; j++) {</p>
		<p>     if (j==2)</p>
		<p>  continue outer;</p>
		<p>     System.out.println("Value for i=" + i + " Value for j=" +j);</p>
		<p> }</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Value for i=1 Value for j=1 </p>
		<p>2) Value for i=2 Value for j=1 </p>
		<p>3) Value for i=2 Value for j=2 </p>
		<p>4) Value for i=3 Value for j=1 </p>
		<p>
				<br />Question 22)Which statement is true of the following code?</p>
		<p>public class Agg{</p>
		<p>public static void main(String argv[]){</p>
		<p> Agg a = new Agg();</p>
		<p> a.go();</p>
		<p> }</p>
		<p> public void go(){</p>
		<p>  DSRoss ds1 = new DSRoss("one");</p>
		<p>  ds1.start();</p>
		<p> }</p>
		<p>}</p>
		<p>class DSRoss extends Thread{</p>
		<p>
				<br />private String sTname="";</p>
		<p>DSRoss(String s){</p>
		<p>sTname = s;</p>
		<p>}</p>
		<p>public void run(){</p>
		<p>notwait();</p>
		<p>System.out.println("finished");</p>
		<p>}</p>
		<p>public void notwait(){</p>
		<p>while(true){</p>
		<p>try{</p>
		<p>System.out.println("waiting");</p>
		<p>wait();</p>
		<p>}catch(InterruptedException ie){}</p>
		<p>System.out.println(sTname);</p>
		<p>notifyAll();</p>
		<p>}</p>
		<p>}</p>
		<p>}</p>
		<p>1) It will cause a compile time error</p>
		<p>2) Compilation and output of "waiting"</p>
		<p>3) Compilation and output of "waiting" followed by "finished"</p>
		<p>4) Runtime error, an exception will be thrown</p>
		<p>
				<br />Question 23)Which of the following methods can be legally inserted in place of the comment //Method Here ? </p>
		<p>class Base{</p>
		<p> public void amethod(int i) { }</p>
		<p>}</p>
		<p>public class Scope extends Base{</p>
		<p> public static void main(String argv[]){</p>
		<p> }</p>
		<p> //Method Here</p>
		<p>}</p>
		<p>1) void amethod(int i) throws Exception {} </p>
		<p>2) void amethod(long i)throws Exception {} </p>
		<p>3) void amethod(long i){} </p>
		<p>4) public void amethod(int i) throws Exception {} </p>
		<p>
				<br />Question 24)Which of the following will output -4.0 </p>
		<p>1) System.out.println(Math.floor(-4.7)); </p>
		<p>2) System.out.println(Math.round(-4.7)); </p>
		<p>3) System.out.println(Math.ceil(-4.7)); </p>
		<p>4) System.out.println(Math.min(-4.7)); </p>
		<p>
				<br />Question 25)What will happen if you attempt to compile and run the following code? </p>
		<p>Integer ten=new Integer(10);</p>
		<p>Long nine=new Long (9);</p>
		<p>System.out.println(ten + nine);</p>
		<p>int i=1;</p>
		<p>System.out.println(i + ten);</p>
		<p>1) 19 followed by 20</p>
		<p>2) 19 followed by 11 </p>
		<p>3) Compile time error </p>
		<p>4) 10 followed by 1 </p>
		<p>
				<br />Question 26)If you run the code below, what gets printed out? </p>
		<p>String s=new String("Bicycle");</p>
		<p>int iBegin=1;</p>
		<p>char iEnd=3;</p>
		<p>System.out.println(s.substring(iBegin,iEnd));</p>
		<p>1) Bic </p>
		<p>2) ic </p>
		<p>3) icy </p>
		<p>4) error: no method matching substring(int,char) </p>
		<p>
				<br />Question 27)If you wanted to find out where the position of the letter v (ie return 2) in the string s containing "Java",which of the following could you use? </p>
		<p>1) mid(2,s); </p>
		<p>2) charAt(2); </p>
		<p>3) s.indexOf('v'); </p>
		<p>4) indexOf(s,'v');</p>
		<p>
				<br />Question 28)Given the following declarations </p>
		<p>String s1=new String("Hello")</p>
		<p>String s2=new String("there");</p>
		<p>String s3=new String();</p>
		<p>Which of the following are legal operations? </p>
		<p>1) s3=s1 + s2; </p>
		<p>2) s3=s1-s2; </p>
		<p>3) s3=s1 &amp; s2; </p>
		<p>4) s3=s1 &amp;&amp; s2 </p>
		<p>
				<br />Question 29)What is the result of the following operation? </p>
		<p>System.out.println(4 | 3); </p>
		<p>1) 6 </p>
		<p>2) 0 </p>
		<p>3) 1 </p>
		<p>4) 7 </p>
		<p>
				<br />Question 30)</p>
		<p>public class MyClass1 {</p>
		<p>public static void main(String argv[]){ }</p>
		<p>/*Modifier at XX */ class MyInner {}</p>
		<p>}</p>
		<p>What modifiers would be legal at XX in the above code? </p>
		<p>1) public </p>
		<p>2) private </p>
		<p>3) static </p>
		<p>4) friend</p>
		<p>
				<br />Question 31)What will happen when you attempt to compile and run the following code?</p>
		<p>public class Holt extends Thread{</p>
		<p>        private String sThreadName; </p>
		<p>        public static void main(String argv[]){</p>
		<p>                Holt h = new Holt();</p>
		<p>                h.go(); </p>
		<p>        }</p>
		<p>Holt(){}</p>
		<p>Holt(String s){</p>
		<p>        sThreadName = s;</p>
		<p>}</p>
		<p>public String getThreadName(){</p>
		<p>        return sThreadName;</p>
		<p>}</p>
		<p>public void go(){</p>
		<p>        Holt first = new Holt("first");</p>
		<p>        first.start();</p>
		<p>        Holt second = new Holt("second");</p>
		<p>        second.start();</p>
		<p>}</p>
		<p>        public void start(){</p>
		<p>                for(int i = 0; i &lt; 2; i ++){</p>
		<p>                        System.out.println(getThreadName() +i);</p>
		<p>                try{</p>
		<p>                        Thread.sleep(100);</p>
		<p>                }catch(InterruptedException e){System.out.println(e.getMessage());}</p>
		<p>                }</p>
		<p>        }</p>
		<p>}</p>
		<p>
				<br />1) Compile time error</p>
		<p>2) Output of first0, second0, first0, second1</p>
		<p>3) Output of first0, first1, second0, second1</p>
		<p>4) Runtime error</p>
		<p>
				<br />Question 32)An Applet has its Layout Manager set to the default of FlowLayout. What code would be correct to change to another Layout Manager. </p>
		<p>1) setLayoutManager(new GridLayout()); </p>
		<p>2) setLayout(new GridLayout(2,2)); </p>
		<p>3) setGridLayout(2,2);</p>
		<p>4) setBorderLayout(); </p>
		<p>
				<br />Question 33)What will happen when you attempt to compile and run the following code?. </p>
		<p>class Background implements Runnable{</p>
		<p> int i=0;</p>
		<p>  public int run(){</p>
		<p>while(true){</p>
		<p>i++;</p>
		<p>System.out.println("i="+i);</p>
		<p>} //End while</p>
		<p>return 1;</p>
		<p>}//End run</p>
		<p>}//End class</p>
		<p>1) It will compile and the run method will print out the increasing value of i. </p>
		<p>2) It will compile and calling start will print out the increasing value of i. </p>
		<p>3) The code will cause an error at compile time. </p>
		<p>4) Compilation will cause an error because while cannot take a parameter of true. </p>
		<p>
				<br />Question 34)Which of the following statements about this code are true?</p>
		<p>public class Morecombe{</p>
		<p>public static void main(String argv[]){</p>
		<p>  Morecombe m = new Morecombe();</p>
		<p>  m.go(new Turing(){}); </p>
		<p>}</p>
		<p>public void go(Turing t){</p>
		<p> t.start();</p>
		<p> }</p>
		<p>}</p>
		<p>class Turing extends Thread{</p>
		<p> public void run(){</p>
		<p>  for(int i =0; i &lt; 2; i++){</p>
		<p>   System.out.println(i);</p>
		<p>  } </p>
		<p> } </p>
		<p>}</p>
		<p>1) Compilation error due to malformed parameter to go method</p>
		<p>2) Compilation error, class Turing has no start method</p>
		<p>3) Compilation and output of 0 followed by 1</p>
		<p>4) Compilation but runtime error</p>
		<p>
				<br />Question 35)What will be the result when you attempt to compile and run the following code?. </p>
		<p>public class Conv{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Conv c=new Conv();</p>
		<p> String s=new String("ello");</p>
		<p> c.amethod(s);</p>
		<p>    }</p>
		<p>    public void amethod(String s){</p>
		<p> char c='H';</p>
		<p> c+=s;</p>
		<p> System.out.println(c);</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Compilation and output the string "Hello"</p>
		<p>2) Compilation and output the string "ello" </p>
		<p>3) Compilation and output the string elloH </p>
		<p>4) Compile time error </p>
		<p>
				<br />Question 36)Given the following code, what test would you need to put in place of the comment line? </p>
		<p>//place test here <br />to result in an output of the string Equal </p>
		<p>public class EqTest{</p>
		<p>  public static void main(String argv[]){</p>
		<p>   EqTest e=new EqTest();</p>
		<p>  }</p>
		<p> EqTest(){</p>
		<p>   String s="Java";</p>
		<p>   String s2="java";</p>
		<p>   //place test here {</p>
		<p>    System.out.println("Equal");</p>
		<p>    }else</p>
		<p>    {</p>
		<p>    System.out.println("Not equal");</p>
		<p>   }</p>
		<p>  }</p>
		<p>}</p>
		<p>1) if(s==s2) </p>
		<p>2) if(s.equals(s2) </p>
		<p>3) if(s.equalsIgnoreCase(s2)) </p>
		<p>4) if(s.noCaseMatch(s2)) </p>
		<p>Question 37)Given the following code </p>
		<p>import java.awt.*;</p>
		<p>public class SetF extends Frame{</p>
		<p>public static void main(String argv[]){</p>
		<p> SetF s=new SetF();</p>
		<p> s.setSize(300,200);</p>
		<p> s.setVisible(true);</p>
		<p> }</p>
		<p>}</p>
		<p>How could you set the frame surface color to pink </p>
		<p>1)s.setBackground(Color.pink); </p>
		<p>2)s.setColor(PINK); </p>
		<p>3)s.Background(pink); </p>
		<p>4)s.color=Color.pink </p>
		<p>
				<br />Question 38)How can you change the current working directory using an instance of the File class called FileName? </p>
		<p>1) FileName.chdir("DirName") </p>
		<p>2) FileName.cd("DirName") </p>
		<p>3) FileName.cwd("DirName") </p>
		<p>4) The File class does not support directly changing the current directory. </p>
		<p>
				<br />Question 39)If you create a TextField  with a constructor to set it to occupy 5 columns, what difference will it make if you use it with a proportional font (ie Times Roman) or a fixed pitch typewriter style font (Courier). </p>
		<p>1)With a fixed font you will see 5 characters, with a  proportional it will depend on the width of the characters </p>
		<p>2)With a fixed font you will see 5 characters,with a  proportional it will cause the field to expand to fit the text 3)The columns setting does not affect the number of characters displayed </p>
		<p>4)Both will show exactly 5 characters </p>
		<p>
				<br />Question 40)Given the following code how could you invoke the Base constructor that will print out the string "base constructor"; </p>
		<p>class Base{</p>
		<p>    Base(int i){</p>
		<p> System.out.println("base constructor");</p>
		<p>    }</p>
		<p>    Base(){</p>
		<p>    }</p>
		<p>}</p>
		<p>public class Sup extends Base{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Sup s= new Sup();</p>
		<p> //One</p>
		<p>    }</p>
		<p>    Sup()</p>
		<p>    {</p>
		<p> //Two</p>
		<p>    }</p>
		<p>    public void derived()</p>
		<p>    {</p>
		<p> //Three</p>
		<p>    }</p>
		<p>}</p>
		<p>1) On the line After //One put Base(10); </p>
		<p>2) On the line After //One put super(10); </p>
		<p>3) On the line After //Two put super(10); </p>
		<p>4) On the line After //Three put super(10); </p>
		<p>
				<br />Question 41)Given the following code what will be output? </p>
		<p>public class Pass{</p>
		<p>    static int j=20;</p>
		<p>    public static void main(String argv[]){</p>
		<p> int i=10;</p>
		<p> Pass p = new Pass();</p>
		<p> p.amethod(i);</p>
		<p> System.out.println(i);</p>
		<p> System.out.println(j);</p>
		<p>    }</p>
		<p>    public void amethod(int x){</p>
		<p> x=x*2;</p>
		<p> j=j*2;</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Error: amethod parameter does not match variable </p>
		<p>2) 20 and 40 </p>
		<p>3) 10 and 40 </p>
		<p>4) 10, and 20 </p>
		<p>
				<br />Question 42)What code placed after the comment //For loop would result in the population of every element of the array ia[] with a value from variable i.? </p>
		<p>public class Lin{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Lin l = new Lin();</p>
		<p> l.amethod();</p>
		<p>    }</p>
		<p>    public void amethod(){</p>
		<p> int ia[] = new int[4];</p>
		<p> //Start For loop</p>
		<p> {</p>
		<p>     ia[i]=i;</p>
		<p>     System.out.println(ia[i]);</p>
		<p> }</p>
		<p>    }</p>
		<p>}</p>
		<p>1) for(int i=0; i &lt; ia.length() -1; i++) </p>
		<p>2) for (int i=0; i&lt; ia.length(); i++) </p>
		<p>3) for(int i=1; i &lt; 4; i++) </p>
		<p>4) for(int i=0; i&lt; ia.length;i++) </p>
		<p>
				<br />Question 43)What will be the result when you try to compile and run the following code? </p>
		<p>private class Base{</p>
		<p>    Base(){</p>
		<p> int i = 100;</p>
		<p> System.out.println(i);</p>
		<p>    }</p>
		<p>}</p>
		<p>public class Pri extends Base{</p>
		<p>    static int i = 200;</p>
		<p>    public static void main(String argv[]){</p>
		<p> Pri p = new Pri();</p>
		<p> System.out.println(i);</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Error at compile time </p>
		<p>2) 200 </p>
		<p>3) 100 followed by 200 </p>
		<p>4) 100 </p>
		<p>
				<br />Question 44)What will the following code print out? </p>
		<p>public class Oct{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Oct o = new Oct();</p>
		<p> o.amethod();</p>
		<p>    }</p>
		<p>    public void amethod(){</p>
		<p> int oi= 012;</p>
		<p> System.out.println(oi);</p>
		<p>    }</p>
		<p>}</p>
		<p>1)12 </p>
		<p>2)012 </p>
		<p>3)10 </p>
		<p>4)10.0 </p>
		<p>
				<br />Question 45)What will happen when you try compiling and running this code? </p>
		<p>public class Ref{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Ref r = new Ref();</p>
		<p> r.amethod(r);</p>
		<p>    }</p>
		<p>    public void amethod(Ref r){</p>
		<p> int i=99;</p>
		<p> multi(r);</p>
		<p> System.out.println(i);</p>
		<p>    }</p>
		<p>    public void multi(Ref r){</p>
		<p> r.i = r.i*2;</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Error at compile time </p>
		<p>2) An output of 99 </p>
		<p>3) An output of 198 </p>
		<p>4) An error at runtime </p>
		<p>
				<br />Question 46)You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique. <br />What interface might be most suitable to meet this need? </p>
		<p>1)Set </p>
		<p>2)List </p>
		<p>3)Map </p>
		<p>4)Vector </p>
		<p>
				<br />Question 47)Which of the following will successfully create an instance of the Vector class and add an element? </p>
		<p>1) Vector v=new Vector(99); </p>
		<p>     v[1]=99; <br />  <br />2) Vector v=new Vector(); </p>
		<p>     v.addElement(99); </p>
		<p>3) Vector v=new Vector(); </p>
		<p>    v.add(99); </p>
		<p>4 Vector v=new Vector(100); </p>
		<p>   v.addElement("99"); </p>
		<p>
				<br />Question 48)You have created a simple Frame and overridden the paint method as follows </p>
		<p>public void paint(Graphics g){</p>
		<p>g.drawString("Dolly",50,10);</p>
		<p>}</p>
		<p>What will be the result when you attempt to compile and run the program? </p>
		<p>1) The string "Dolly" will be displayed at the centre of the frame </p>
		<p>2) An error at compilation complaining at the signature of the paint method </p>
		<p>3) The lower part of the word Dolly will be seen at the top of the frame, with the top hidden. </p>
		<p>4) The string "Dolly" will be shown at the bottom of the frame. </p>
		<p>
				<br />Question 49)What will be the result when you attempt to compile this program? </p>
		<p>public class Rand{</p>
		<p>    public static void main(String argv[]){</p>
		<p> int iRand;</p>
		<p> iRand = Math.random();</p>
		<p> System.out.println(iRand);</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Compile time error referring to a cast problem </p>
		<p>2) A random number between 1 and 10 </p>
		<p>3) A random number between 0 and 1 </p>
		<p>4) A compile time error about random being an unrecognised method </p>
		<p>
				<br />Question 50)Given the following code </p>
		<p>import java.io.*;</p>
		<p>public class Th{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Th t = new Th();</p>
		<p> t.amethod();</p>
		<p>    }</p>
		<p>    public void amethod(){</p>
		<p> try{</p>
		<p>     ioCall();</p>
		<p> }catch(IOException ioe){}</p>
		<p>    }</p>
		<p>}</p>
		<p>What code would be most likely for the body of the ioCall method </p>
		<p>1) public void ioCall ()throws IOException{</p>
		<p> DataInputStream din = new DataInputStream(System.in);</p>
		<p> din.readChar();</p>
		<p> }</p>
		<p>2) public void ioCall ()throw IOException{</p>
		<p> DataInputStream din = new DataInputStream(System.in);</p>
		<p> din.readChar();</p>
		<p> }</p>
		<p>3) public void ioCall (){</p>
		<p> DataInputStream din = new DataInputStream(System.in);</p>
		<p> din.readChar();</p>
		<p> }</p>
		<p>4) public void ioCall throws IOException(){</p>
		<p>
				<br /> DataInputStream din = new DataInputStream(System.in);</p>
		<p> din.readChar();</p>
		<p>}</p>
		<p>
				<br />Question 51)What will happen when you compile and run the following code? </p>
		<p>public class Scope{</p>
		<p>    private int i;</p>
		<p>    public static void main(String argv[]){</p>
		<p> Scope s = new Scope();</p>
		<p> s.amethod();</p>
		<p>    }//End of main</p>
		<p>    public static void amethod(){</p>
		<p> System.out.println(i);</p>
		<p>    }//end of amethod</p>
		<p>}//End of class</p>
		<p>1) A value of 0 will be printed out </p>
		<p>2) Nothing will be printed out </p>
		<p>3) A compile time error </p>
		<p>4) A compile time error complaining of the scope of the variable i </p>
		<p>
				<br />Question 52)You want to lay out a set of buttons horizontally but with more space between the first button and the rest. You are going to use the GridBagLayout manager to control the way the buttons are set out. How will you modify the way the GridBagLayout acts in order to change the spacing around the first button? </p>
		<p>1) Create an instance of the GridBagConstraints class, call the weightx() method and then pass the GridBagConstraints instance with the component to the setConstraints method of the GridBagLayout class. </p>
		<p>2) Create an instance of the GridBagConstraints class, set the weightx field and then pass the GridBagConstraints instance with the component to the setConstraints method of the GridBagLayout class. </p>
		<p>3) Create an instance of the GridBagLayout class, set the weightx field and then call the setConstraints method of the GridBagLayoutClass with the component as a parameter. </p>
		<p>4) Create an instance of the GridBagLayout class, call the setWeightx() method and then pass the GridBagConstraints instance with the component to the setConstraints method of the GridBagLayout class. </p>
		<p>
				<br />Question 53)Which of the following can you perform using the File class? </p>
		<p>1) Change the current directory </p>
		<p>2) Return the name of the parent directory </p>
		<p>3) Delete a file </p>
		<p>4) Find if a file contains text or binary information </p>
		<p>
				<br />Question 54)Which statement is true of the following code?</p>
		<p>public class Rpcraven{</p>
		<p> public static void main(String argv[]){</p>
		<p> Pmcraven pm1 = new Pmcraven("One");</p>
		<p> pm1.run();</p>
		<p> Pmcraven pm2 = new Pmcraven("Two");</p>
		<p> pm2.run();</p>
		<p> }</p>
		<p>}</p>
		<p>class Pmcraven extends Thread{</p>
		<p>private String sTname="";</p>
		<p>Pmcraven(String s){</p>
		<p> sTname = s;</p>
		<p>}</p>
		<p>public void run(){</p>
		<p> for(int i =0; i &lt; 2 ; i++){</p>
		<p>  try{</p>
		<p>   sleep(1000);</p>
		<p>  }catch(InterruptedException e){}</p>
		<p>  yield();</p>
		<p>  System.out.println(sTname);</p>
		<p>  }</p>
		<p> }</p>
		<p>}</p>
		<p>1) Compile time error, class Rpcraven does not import java.lang.Thread</p>
		<p>2) Output of One One Two Two</p>
		<p>3) Output of One Two One Two</p>
		<p>4) Compilation but no output at runtime</p>
		<p>
				<br />Question 55)You are concerned that your program may attempt to use more memory than is available. To avoid this situation you want to ensure that the Java Virtual Machine will run its garbage collection just before you start a complex routine. What can you do to be certain that garbage collection will run when you want . </p>
		<p>1) You cannot be certain when garbage collection will run </p>
		<p>2) Use the Runtime.gc() method to force garbage collection </p>
		<p>3) Ensure that all the variables you require to be garbage collected are set to null </p>
		<p>4) Use the System.gc() method to force garbage collection</p>
		<p>
				<br />Question 56)You are using the GridBagLayout manager to place a series of buttons on a Frame. You want to make the size of one of the buttons bigger than the text it contains. Which of the following will allow you to do that?</p>
		<p>1) The GridBagLayout manager does not allow you to do this </p>
		<p>2) The setFill method of the GridBagLayout class </p>
		<p>3) The setFill method of the GridBagConstraints class </p>
		<p>4) The fill field of the GridBagConstraints class </p>
		<p>
				<br />Question 57)Which of the following most closely describes a bitset collection? </p>
		<p>1) A class that contains groups of unique sequences of bits </p>
		<p>2) A method for flipping individual bits in instance of a primitive type </p>
		<p>3) An array of boolean primitives that indicate zeros or ones </p>
		<p>4) A collection for storing bits as on-off information, like a vector of bits </p>
		<p>
				<br />Question 58)You have these files in the same directory. What will happen when you attempt to compile and run Class1.java if you have not already compiled Base.java </p>
		<p>//Base.java</p>
		<p>package Base;</p>
		<p>class Base{</p>
		<p>    protected void amethod(){</p>
		<p> System.out.println("amethod");</p>
		<p>    }//End of amethod</p>
		<p>}//End of class base</p>
		<p>package Class1;</p>
		<p>//Class1.java</p>
		<p>public class Class1 extends Base{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Base b = new Base();</p>
		<p> b.amethod();</p>
		<p>    }//End of main</p>
		<p>}//End of Class1</p>
		<p>1) Compile Error: Methods in Base not found </p>
		<p>2) Compile Error: Unable to access protected method in base class </p>
		<p>3) Compilation followed by the output "amethod" </p>
		<p>4)Compile error: Superclass Class1.Base of class Class1.Class1 not found </p>
		<p>
				<br />Question 59)What will happen when you attempt to compile and run the following code </p>
		<p>class Base{</p>
		<p>    private void amethod(int iBase){</p>
		<p> System.out.println("Base.amethod");</p>
		<p>    }</p>
		<p>}</p>
		<p>class Over extends Base{</p>
		<p>    public static void main(String argv[]){</p>
		<p> Over o = new Over();</p>
		<p> int iBase=0;</p>
		<p> o.amethod(iBase);</p>
		<p>    }</p>
		<p>    public void amethod(int iOver){</p>
		<p> System.out.println("Over.amethod");</p>
		<p>    }</p>
		<p>}</p>
		<p>1) Compile time error complaining that Base.amethod is private </p>
		<p>2) Runtime error complaining that Base.amethod is private </p>
		<p>3) Output of "Base.amethod"</p>
		<p>4) Output of "Over.amethod" </p>
		<p>
				<br />Question 60)You are creating an applet with a Frame that contains buttons. You are using the GridBagLayout manager and you have added Four buttons. At the moment the buttons appear in the centre of the frame from left to right. You want them to appear one on top of the other going down the screen. What is the most appropriate way to do this. </p>
		<p>1) Set the gridy value of the GridBagConstraints class to a value increasing from 1 to 4 </p>
		<p>2) set the fill value of the GridBagConstraints class to VERTICAL </p>
		<p>3) Set the ipady value of the GridBagConstraints class to a value increasing from 0 to 4 </p>
		<p>4) Set the fill value of the GridBagLayouts class to GridBag.VERTICAL </p>
		<p> </p>
<img src ="http://www.blogjava.net/bily/aggbug/81630.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 21:42 <a href="http://www.blogjava.net/bily/articles/81630.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java题库格林模拟试题答案</title><link>http://www.blogjava.net/bily/articles/81625.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 13:18:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81625.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81625.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81625.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81625.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81625.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Answers （1）________________________________________Answer 1)		5) int i=10; 		explanation: 		1) float f=1.3; 		Will not compile because the default type of a number with a floating point compon...&nbsp;&nbsp;<a href='http://www.blogjava.net/bily/articles/81625.html'>阅读全文</a><img src ="http://www.blogjava.net/bily/aggbug/81625.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 21:18 <a href="http://www.blogjava.net/bily/articles/81625.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java笔试题集（三）</title><link>http://www.blogjava.net/bily/articles/81604.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 12:50:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81604.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81604.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81604.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81604.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81604.html</trackback:ping><description><![CDATA[<p>[第一部分：选择题] </p>
<p>QUESTION NO: 1 </p>
<p>1、public class Test { <br />
&nbsp; public static void changeStr(String str){ <br />
&nbsp;&nbsp;&nbsp; str="welcome"; <br />
&nbsp; } <br />
&nbsp; public static void main(String[] args) { <br />
&nbsp;&nbsp;&nbsp; String str="1234"; <br />
&nbsp;&nbsp;&nbsp; changeStr(str); <br />
&nbsp;&nbsp;&nbsp; System.out.println(str); <br />
&nbsp; } <br />
} <br />
Please write the output result ： </p>
<p>QUESTION NO:2 </p>
<p>1. public class Test { <br />
2. static boolean foo(char c) { <br />
3. System.out.print(c); <br />
4. return true; <br />
5. } <br />
6. public static void main( String[] argv ) { <br />
7. int i =0; <br />
8. for ( foo(&#8217;A&#8217;); foo(&#8217;B&#8217;)&amp;&amp;(i&lt;2); foo(&#8217;C&#8217;)){ <br />
9. i++ ; <br />
10. foo(&#8217;D&#8217;); <br />
12. } <br />
13. } <br />
14. } <br />
What is the result? </p>
<p>A. ABDCBDCB <br />
B. ABCDABCD <br />
C. Compilation fails. <br />
D. An exception is thrown at runtime. </p>
<p>QUESTION NO: 3 </p>
<p>1. class A { <br />
2. protected int method1(int a, int b) { return 0; } <br />
3. } <br />
Which two are valid in a class that extends class A? (Choose two) <br />
A. public int method1(int a, int b) { return 0; }<br />
B. private int method1(int a, int b) { return 0; } <br />
C. private int method1(int a, long b) { return 0; } <br />
D. public short method1(int a, int b) { return 0; } <br />
E. static protected int method1(int a, int b) { return 0; } </p>
<p>QUESTION NO: 4 </p>
<p>1. public class Outer{ <br />
2. public void someOuterMethod() { <br />
3. // Line 3 <br />
4. } <br />
5. public class Inner{} <br />
6. public static void main( String[]argv ) { <br />
7. Outer o = new Outer(); <br />
8. // Line 8 <br />
9. } <br />
10. } <br />
Which instantiates an instance of Inner? <br />
A. new Inner(); // At line 3 <br />
B. new Inner(); // At line 8 <br />
C. new o.Inner(); // At line 8 <br />
D. new Outer.Inner(); // At line 8//new Outer().new Inner() </p>
<p>QUESTION NO: 5 </p>
<p>Which method is used by a servlet to place its session ID in a URL that is written to the servlet&#8217;s response output stream? <br />
A. The encodeURL method of the HttpServletRequest interface. <br />
B. The encodeURL method of the HttpServletResponse interface. <br />
C. The rewriteURL method of the HttpServletRequest interface.<br />
D. The rewriteURL method of the HttpServletResponse interface. </p>
<p>QUESTION NO: 6 </p>
<p>Which of the following statements regarding the lifecycle of a session bean are correct?&nbsp; <br />
1. java.lang.IllegalStateException is thrown if SessionContext.getEJBObject() is invoked when a stateful session bean instance is passivated.&nbsp; <br />
2. SessionContext.getRollbackOnly() does not throw an exception when a session bean with bean-managed transaction demarcation is activated.&nbsp; <br />
3. An exception is not thrown when SessionContext.getUserTransaction() is called in the afterBegin method of a bean with container-managed transactions.&nbsp; <br />
4. JNDI access to java:comp/env is permitted in all the SessionSynchronization methods of a stateful session bean with container-managed transaction demarcation.&nbsp; <br />
5. Accessing resource managers in the SessionSynchronization.afterBegin method of a stateful session bean with bean-managed transaction does not throw an exception. </p>
<p>[第二部分：概念题]</p>
<p>1．&nbsp;&nbsp; 描述Struts体系结构？对应各个部分的开发工作主要包括哪些？</p>
<p>2．&nbsp;&nbsp; XML包括哪些解释技术，区别是什么？</p>
<p>3．&nbsp;&nbsp; JSP有哪些内置对象和动作？它们的作用分别是什么？</p>
<p>4、SQL问答题</p>
<p>SELECT * FROM TABLE</p>
<p>和</p>
<p>SELECT * FROM TABLE </p>
<p>WHERE NAME LIKE '%%' AND ADDR LIKE '%%' </p>
<p>AND (1_ADDR LIKE '%%' OR 2_ADDR LIKE '%%' </p>
<p>OR 3_ADDR LIKE '%%' OR 4_ADDR LIKE '%%' ) </p>
<p>的检索结果为何不同？</p>
<p>5、SQL问答题</p>
<p>表结构：</p>
<p>1、&nbsp;&nbsp; 表名：g_cardapply</p>
<p>字段(字段名/类型/长度)：</p>
<p>g_applyno&nbsp;&nbsp;&nbsp;&nbsp; varchar&nbsp;&nbsp; 8；//申请单号（关键字）</p>
<p>g_applydate&nbsp;&nbsp; bigint&nbsp;&nbsp; 8；//申请日期</p>
<p>g_state&nbsp;&nbsp;&nbsp;&nbsp; varchar&nbsp;&nbsp; 2；//申请状态</p>
<p>2、&nbsp;&nbsp; 表名：g_cardapplydetail</p>
<p>字段(字段名/类型/长度)：</p>
<p>g_applyno&nbsp;&nbsp;&nbsp;&nbsp; varchar&nbsp;&nbsp; 8；//申请单号（关键字）</p>
<p>g_name&nbsp;&nbsp;&nbsp;&nbsp; varchar&nbsp;&nbsp; 30；//申请人姓名</p>
<p>g_idcard&nbsp;&nbsp;&nbsp;&nbsp; varchar&nbsp;&nbsp; 18；//申请人身份证号</p>
<p>g_state&nbsp;&nbsp;&nbsp;&nbsp; varchar&nbsp;&nbsp; 2；//申请状态</p>
<p>其中，两个表的关联字段为申请单号。</p>
<p>题目：</p>
<p>1、&nbsp;&nbsp; 查询身份证号码为440401430103082的申请日期</p>
<p>2、&nbsp;&nbsp; 查询同一个身份证号码有两条以上记录的身份证号码及记录个数</p>
<p>3、&nbsp;&nbsp; 将身份证号码为440401430103082的记录在两个表中的申请状态均改为07</p>
<p>4、&nbsp;&nbsp; 删除g_cardapplydetail表中所有姓李的记录</p>
<p>[JAVA题库:5道JAVA题]</p>
<p>Module 1 &#8211; Getting Started</p>
<p>Q1.What will happen when you compile and run the following code? </p>
<p>(4)</p>
<p>public class MyClass{<br />
static int i;<br />
public static void main(String argv[]){<br />
System.out.println(i);<br />
}<br />
}</p>
<p>1) Error Variable i may not have been initialized <br />
2) null <br />
3) 1 <br />
4) 0 </p>
<p>Q2.Which of the following will compile without error (2)(3)<br />
1) <br />
import java.awt.*;<br />
package Mypackage;<br />
class Myclass {}<br />
2) <br />
package MyPackage;<br />
import java.awt.*;<br />
class MyClass{}<br />
3) <br />
/*This is a comment */<br />
package MyPackage;<br />
import java.awt.*;<br />
class MyClass{}</p>
<p>Q3.What will happen if you try to compile and run the following code (1)<br />
public class MyClass {<br />
public static void main(String arguments[]) {<br />
amethod(arguments);<br />
}<br />
public void amethod(String[] arguments) {<br />
System.out.println(arguments);<br />
System.out.println(arguments[1]);<br />
}<br />
}<br />
1) error Can't make static reference to void amethod. <br />
2) error method main not correct <br />
3) error array must include parameter <br />
4) amethod must be declared with String</p>
<p>Q4.Given the following code（2）<br />
public class Sytch{<br />
int x=2000;<br />
public static void main(String argv[]){<br />
System.out.println("Ms "+argv[1]+"Please pay $"+x);<br />
}<br />
What will happen if you attempt to compile and run this code with the command line<br />
java Sytch Jones Diggle<br />
1) Compilation and output of Ms Diggle Please pay $2000<br />
2) Compile time error<br />
3) Compilation and output of Ms Jones Please pay $2000<br />
4) Compilation but runtime error</p>
<p>Q5.You have a public class called myclass with the main method defined as follows(4)<br />
public static void main(String parm[]){<br />
System.out.println(parm[0]);<br />
}</p>
<p>If you attempt to compile the class and run the program as follows<br />
java myclass hello<br />
What will happen?<br />
1) Compile time error, main is not correctly defined<br />
2) Run time error, main is not correctly defined<br />
3) Compilation and output of java<br />
4) Compilation and output of hello</p>
<p>[JAVA题库:考考你]</p>
<p>1、Examine the following code which includes an inner class: </p>
<p>&nbsp;public final class Test4{ <br />
&nbsp; class Inner{ <br />
&nbsp;&nbsp;&nbsp; void test(){ <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (Test4.this.flag);{ <br />
&nbsp;&nbsp;&nbsp;&nbsp; sample(); <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp;&nbsp; } <br />
&nbsp;}<br />
&nbsp;<br />
&nbsp;private boolean flag=false; <br />
&nbsp;public void sample(){ <br />
&nbsp;System.out.println("Sample"); <br />
&nbsp;} <br />
&nbsp;public Test4(){ <br />
&nbsp;(new Inner()).test(); <br />
&nbsp;} <br />
&nbsp;public static void main(String args[]){ <br />
&nbsp;new Test4(); <br />
&nbsp;} <br />
&nbsp;} </p>
<p>&nbsp;What is the result: <br />
　　 A.Print out &#8220;Sample&#8221; <br />
　　 B.Program produces no output but termiantes correctly. <br />
　　 C. Program does not terminate. <br />
　　 D.The program will not compile </p>
<p>答案:A</p>
<p>2、What will happen when you attempt to compile and run the following code?</p>
<p>class Base {<br />
&nbsp;&nbsp;&nbsp; int i = 99;<br />
&nbsp;&nbsp;&nbsp; public void amethod() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Base.amethod()");<br />
&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp;&nbsp; Base() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; amethod();<br />
&nbsp;&nbsp;&nbsp; }<br />
}</p>
<p>public class Derived extends Base{<br />
&nbsp;&nbsp;&nbsp; int i = -1;<br />
&nbsp;&nbsp;&nbsp; public static void main(String argv[]) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Base b = new Derived();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(b.i);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b.amethod();<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp; public void amethod() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("Derived.amethod()");<br />
&nbsp;&nbsp;&nbsp; }<br />
}</p>
<p>&nbsp;A. Derived.amethod()<br />
&nbsp;&nbsp;&nbsp; -1<br />
&nbsp;&nbsp;&nbsp; Derived.amethod()</p>
<p>&nbsp;B. Derived.amethod()<br />
&nbsp;&nbsp;&nbsp; 99<br />
&nbsp;&nbsp;&nbsp; Derived.amethod()<br />
&nbsp;C. 99<br />
&nbsp;&nbsp;&nbsp; Derived.amethod()<br />
&nbsp;D.<br />
&nbsp;&nbsp;&nbsp; Compile time error</p>
<p>答案:B</p>
<p>3、public class Test{ <br />
&nbsp;&nbsp;&nbsp;&nbsp; public static void main(String[] args){ <br />
&nbsp;&nbsp;&nbsp;&nbsp; StringBuffer a=new StringBuffer("A"); <br />
&nbsp;&nbsp;&nbsp;&nbsp; StringBuffer b=new StringBuffer("B"); <br />
&nbsp;&nbsp;&nbsp;&nbsp; operate(a,b); <br />
&nbsp;&nbsp;&nbsp;&nbsp; System.out.pintln(a+","+b); <br />
&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp; public static void operate(StringBuffer x, StringBuffer y){ <br />
&nbsp;&nbsp;&nbsp; x.append(y); <br />
&nbsp;&nbsp;&nbsp; y=x; <br />
&nbsp;&nbsp; } <br />
&nbsp;&nbsp; } </p>
<p>what is the output? </p>
<p>答案:"AB,B"</p>
<p>4、public class Test{ <br />
&nbsp;&nbsp; public static void stringReplace(String text){ <br />
&nbsp;&nbsp;&nbsp;&nbsp; text=text.replace('j','l'); <br />
&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp;&nbsp; public static void bufferReplace(StringBuffer text){ <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; text=text.append("c"); <br />
&nbsp;&nbsp;&nbsp;&nbsp; } <br />
&nbsp;&nbsp; public static void main(String args[]){&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String textString=new String("java"); <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuffer textBuffer=new StringBuffer("java"); <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stringReplace(textString); <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bufferReplace(textBuffer); <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(textString+textBuffer); <br />
&nbsp;&nbsp;&nbsp; } <br />
&nbsp;} <br />
&nbsp;&nbsp; what is the output? </p>
<p>答案:"javajavac" </p>
<p>5、public class Test{ <br />
&nbsp; static void leftshift(int i, int j){ <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i&lt;&lt;=j; <br />
&nbsp; } </p>
<p>&nbsp; public static void main(String args[]){ <br />
&nbsp;&nbsp;&nbsp; int i=4, j=2; </p>
<p>&nbsp;&nbsp; leftshift(i,j); <br />
&nbsp;&nbsp; System.out.println(i); <br />
&nbsp;} <br />
} <br />
what is the result?</p>
<p>答案:4</p>
<p>Java编程练习题库 </p>
<p>【1】编译运行如下程序的结果是什么 ？ <br />
&nbsp; class InvalidIndexException extends Exception{<br />
&nbsp; private int i;<br />
&nbsp; InvalidIndexException(int a){<br />
&nbsp;&nbsp;&nbsp; i=a;<br />
&nbsp; }<br />
&nbsp; public String toString(){<br />
&nbsp;&nbsp;&nbsp; return i+" is out of boundary--0 &lt; i &lt; 8";<br />
&nbsp; }<br />
}</p>
<p>public class Weekdays{</p>
<p>&nbsp; public static void main(String args[]){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i=1; i &lt; 9; i++) System.out.println(i+"---"+giveName(i));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }catch(InvalidIndexException e){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(e.toString());<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }finally{ System.out.println("These days makes up a week.");}<br />
&nbsp; }</p>
<p>&nbsp; public static String giveName(int d) {<br />
&nbsp;&nbsp;&nbsp; String name;<br />
&nbsp;&nbsp;&nbsp; switch(d){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 1: name="Monday"; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 2: name="Tuesday"; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 3: name="Wednesday"; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 4: name="Thursday"; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 5: name="Friday"; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 6: name="Saturday"; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 7: name="Sunday"; break;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: throw new InvalidIndexException(d);<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; return name;<br />
&nbsp; }<br />
}</p>
<p>（A）&nbsp; 1---Monday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2---Tuesday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3---Wednesday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4---Thursday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5---Friday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6---Saturday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7---Sunday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; These days makes up a week.<br />
（B）&nbsp; 1---Monday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2---Tuesday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3---Wednesday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4---Thursday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5---Friday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6---Saturday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7---Sunday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8 is out of boundary--0 &lt; i &lt; 8<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; These days makes up a week. <br />
（C）&nbsp; 1---Monday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2---Tuesday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3---Wednesday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4---Thursday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5---Friday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6---Saturday<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7---Sunday<br />
（D） 编 译 不 能 通 过。</p>
<p>答 案:(B) </p>
<p>【2】 有 如 下 一 段Java 程 序： <br />
import java.io.*;<br />
public class Quiz1{<br />
&nbsp;&nbsp;&nbsp; public static void main(String arg[]){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int i;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("Go ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("in ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i=System.in.read();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (i=='0') {throw new MyException();}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("this ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(IOException e){}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch(MyException e){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("that ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("way.\n");<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
class MyException extends Exception{}<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 运 行 该 程 序 后 输 入 字 符'0', 请 问 运 行 结 果 为 何 ？ <br />
（A）Go in this way<br />
（B）Go in that this way<br />
（C）Go in that<br />
（D）Go in that way </p>
<p>答 案:(D) </p>
<p>【3】 下 面 程 序 的 输 出 是 什 么 ？ <br />
&nbsp;&nbsp;&nbsp; public class Quiz2{<br />
&nbsp;&nbsp;&nbsp; public static void main(String args[]){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try {throw new MyException();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }catch(Exception e){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("It's caught!");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }finally{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println("It's finally caught!");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<br />
}<br />
class MyException extends Exception{}</p>
<p>（A）It's finally caught!<br />
（B）It's caught!<br />
（C）It's caught!<br />
&nbsp;&nbsp;&nbsp;&nbsp; It's finally caught! <br />
（D）无 输 出</p>
<p>答 案:(C) </p>
<p>【4】 下 面 的 程 序 是 一 个 嵌 套 例 外 处 理 的 例 子， 请 选 择 其 运 行 结 果： <br />
&nbsp;&nbsp;&nbsp; public class Quiz3{<br />
&nbsp;&nbsp;&nbsp; public static void main(String args[]){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int i;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int j=0;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i=1/j;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }catch(Exception e){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("Caught ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw e;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }finally{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("Inside ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }catch(Exception e){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("Caught ");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }finally{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.print("Outside\n");<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp; }<br />
}</p>
<p>（A）Caught Outside<br />
（B）Caught Inside<br />
（C）Caught Caught Outside<br />
（D）Caught Inside Caught Outside<br />
&nbsp;<br />
答 案:(D) </p>
<p>【5】Java 运 行 时 例 外 是 在 运 行Java 程 序 时 由Java 运 行 时 系 统 负 责 抛 出 的 一 系 列 例 外。 本 章 例 程 中 所 提 到 的 许 多 例 外 就 是Java 运 行 时 例 外（ 详 见 例8.2 等）。 请 详 细 阅 读 例 程， 选 择 对 于 如 下 的 程 序， 系 统 将 抛 出 哪 个 运 行 时 例 外。 <br />
class Quiz4{<br />
&nbsp;&nbsp;&nbsp; int a[]=new int[10];<br />
&nbsp;&nbsp;&nbsp; a[10]=0;<br />
}</p>
<p>（A）ArithmeticException<br />
（B）ArrayIndexOutOfBoundsException <br />
（C）NegativeArraySizeException<br />
（D）IllegalArgumentException</p>
<p>答 案:(B) </p>
<p>【6】 为 了 编 程 需 要， 现 需 自 己 编 写 一 个 例 外 类。 一 般 说 来， 下 面 声 明 哪 个 最 为 合 适 ？ <br />
（A）class myClass extentds Exception{...<br />
（B）class myException extends Error{...<br />
（C）class myException extends RuntimeException{...<br />
（D）class myException extends Exception{... </p>
<p>答 案:(D) </p>
<img src ="http://www.blogjava.net/bily/aggbug/81604.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 20:50 <a href="http://www.blogjava.net/bily/articles/81604.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java面试题集（四）</title><link>http://www.blogjava.net/bily/articles/81603.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 12:48:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81603.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81603.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81603.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81603.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81603.html</trackback:ping><description><![CDATA[<p>1. java中的异常处理机制的简单原理和应用。<br />
&nbsp;&nbsp;&nbsp; 当java程序违反了java的语义规则时，java虚拟机就会将发生的错误表示为一个异常。违反语义规则包括2种情况。一种是java类库内置的语义检查。例如数组下标越界,会引发indexoutofboundsexception;访问null的对象时会引发nullpointerexception。另一种情况就是java允许程序员扩展这种语义检查，程序员可以创建自己的异常，并自由选择在何时用throw关键字引发异常。所有的异常都是java.lang.thowable的子类。 </p>
<p>2. java的接口和c++的虚类的相同和不同处。 </p>
<p>&nbsp;&nbsp;&nbsp; 由于java不支持多继承，而有可能某个类或对象要使用分别在几个类或对象里面的方法或属性，现有的单继承机制就不能满足要求。与继承相比，接口有更高的灵活性，因为接口中没有任何实现代码。当一个类实现了接口以后，该类要实现接口里面所有的方法和属性，并且接口里面的属性在默认状态下面都是public static,所有方法默认情况下是public.一个类可以实现多个接口。 </p>
<p>3. 垃圾回收的优点和原理。并考虑2种回收机制。 </p>
<p>&nbsp;&nbsp;&nbsp; java语言中一个显著的特点就是引入了垃圾回收机制，使c++程序员最头疼的内存管理的问题迎刃而解，它使得java程序员在编写程序的时候不再需要考虑内存管理。由于有个垃圾回收机制，java中的对象不再有&#8220;作用域&#8221;的概念，只有对象的引用才有&#8220;作用域&#8221;。垃圾回收可以有效的防止内存泄露，有效的使用可以使用的内存。垃圾回收器通常是作为一个单独的低级别的线程运行，不可预知的情况下对内存堆中已经死亡的或者长时间没有使用的对象进行清楚和回收，程序员不能实时的调用垃圾回收器对某个对象或所有对象进行垃圾回收。回收机制有分代复制垃圾回收和标记垃圾回收，增量垃圾回收。 </p>
<p>4. 请说出你所知道的线程同步的方法。 <br />
&nbsp;&nbsp;&nbsp; wait():使一个线程处于等待状态，并且释放所持有的对象的lock。 <br />
&nbsp;&nbsp;&nbsp; sleep():使一个正在运行的线程处于睡眠状态，是一个静态方法，调用此方法要捕捉interruptedexception异常。 <br />
&nbsp;&nbsp;&nbsp; notify():唤醒一个处于等待状态的线程，注意的是在调用此方法的时候，并不能确切的唤醒某一个等待状态的线程，而是由jvm确定唤醒哪个线程，而且不是按优先级。 <br />
&nbsp;&nbsp;&nbsp; allnotity():唤醒所有处入等待状态的线程，注意并不是给所有唤醒线程一个对象的锁，而是让它们竞争。 </p>
<p>5. 请讲一讲析构函数和虚函数的用法和作用。 </p>
<p>6. error与exception有什么区别？ <br />
&nbsp;&nbsp;&nbsp; error表示系统级的错误和程序不必处理的异常， <br />
&nbsp;&nbsp;&nbsp; exception表示需要捕捉或者需要程序进行处理的异常。 </p>
<p>7. 在java中一个类被声明为final类型，表示了什么意思？ <br />
&nbsp;&nbsp;&nbsp; 表示该类不能被继承，是顶级类。 </p>
<p>8. 描述一下你最常用的编程风格。 </p>
<p>9. heap和stack有什么区别。 <br />
&nbsp;&nbsp;&nbsp; 栈是一种线形集合，其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进行处理。 <br />
&nbsp;&nbsp;&nbsp; 堆是栈的一个组成元素 </p>
<p>10. 如果系统要使用超大整数（超过long长度范围），请你设计一个数据结构来存储这种超大型数字以及设计一种算法来实现超大整数加法运算）。 <br />
public class bigint() <br />
{ <br />
int[] arrone = new arrone[1000]; <br />
string intstring=""; <br />
public int[] arr(string s) { <br />
intstring = s; <br />
for(int i=0;i&lt;arrone.leght;i++) { <br />
11. 如果要设计一个图形系统，请你设计基本的图形元件(point,line,rectangle, triangle)的简单实现 </p>
<p>12. 谈谈final, finally, finalize的区别。 </p>
<p>　　final?修饰符（关键字）如果一个类被声明为final，意味着它不能再派生出新的子类，不能作为父类被继承。因此一个类不能既被声明为 abstract的，又被声明为final的。将变量或方法声明为final，可以保证它们在使用中不被改变。被声明为final的变量必须在声明时给定初值，而在以后的引用中只能读取，不可修改。被声明为final的方法也同样只能使用，不能重载。 <br />
　　finally?再异常处理时提供 finally 块来执行任何清除操作。如果抛出一个异常，那么相匹配的 catch 子句就会执行，然后控制就会进入 finally 块（如果有的话）。 <br />
　　finalize?方法名。java 技术允许使用 finalize() 方法在垃圾收集器将对象从内存中清除出去之前做必要的清理工作。这个方法是由垃圾收集器在确定这个对象没有被引用时对这个对象调用的。它是在 object 类中定义的，因此所有的类都继承了它。子类覆盖&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
finalize() 方法以整理系统资源或者执行其他清理工作。finalize() 方法是在垃圾收集器删除对象之前对这个对象调用的。 </p>
<p>13. anonymous inner class (匿名内部类) 是否可以extends(继承)其它类，是否可以implements(实现)interface(接口)? <br />
　　匿名的内部类是没有名字的内部类。不能extends(继承) 其它类，但一个内部类可以作为一个接口，由另一个内部类实现。 </p>
<p>14. static nested class 和 inner class的不同，说得越多越好(面试题有的很笼统)。 <br />
　　nested class （一般是c++的说法），inner class (一般是java的说法)。java内部类与c++嵌套类最大的不同就在于是否有指向外部的引用上。具体可见http: //www.frontfree.net/articles/services/view.asp?id=704&amp;page=1 <br />
　　注： 静态内部类（inner class）意味着1创建一个static内部类的对象，不需要一个外部类对象，2不能从一个static内部类的一个对象访问一个外部类对象 </p>
<p>15. &amp;和&amp;&amp;的区别。 <br />
　　&amp;是位运算符。&amp;&amp;是布尔逻辑运算符。 </p>
<p>16. hashmap和hashtable的区别。 <br />
　　都属于map接口的类，实现了将惟一键映射到特定的值上。 <br />
　　hashmap 类没有分类或者排序。它允许一个 null 键和多个 null 值。 <br />
　　hashtable 类似于 hashmap，但是不允许 null 键和 null 值。它也比 hashmap 慢，因为它是同步的。</p>
<p>17. collection 和 collections的区别。 <br />
　　collections是个java.util下的类，它包含有各种有关集合操作的静态方法。 <br />
　　collection是个java.util下的接口，它是各种集合结构的父接口。 </p>
<p>18. 什么时候用assert。 <br />
　　断言是一个包含布尔表达式的语句，在执行这个语句时假定该表达式为 true。如果表达式计算为 false，那么系统会报告一个 assertionerror。它用于调试目的： <br />
assert(a &gt; 0); // throws an assertionerror if a &lt;= 0 <br />
断言可以有两种形式： <br />
assert expression1 ; <br />
assert expression1 : expression2 ; <br />
　　expression1 应该总是产生一个布尔值。 <br />
　　expression2 可以是得出一个值的任意表达式。这个值用于生成显示更多调试信息的 string 消息。 <br />
　　断言在默认情况下是禁用的。要在编译时启用断言，需要使用 source 1.4 标记： <br />
　　javac -source 1.4 test.java <br />
　　要在运行时启用断言，可使用 -enableassertions 或者 -ea 标记。 <br />
　　要在运行时选择禁用断言，可使用 -da 或者 -disableassertions 标记。 <br />
　　要系统类中启用断言，可使用 -esa 或者 -dsa 标记。还可以在包的基础上启用或者禁用断言。 <br />
　　可以在预计正常情况下不会到达的任何位置上放置断言。断言可以用于验证传递给私有方法的参数。不过，断言不应该用于验证传递给公有方法的参数，因为不管是否启用了断言，公有方法都必须检查其参数。不过，既可以在公有方法中，也可以在非公有方法中利用断言测试后置条件。另外，断言不应该以任何方式改变程序的状态。 </p>
<p>19. gc是什么? 为什么要有gc? (基础)。 <br />
　　gc是垃圾收集器。java 程序员不用担心内存管理，因为垃圾收集器会自动进行管理。要请求垃圾收集，可以调用下面的方法之一： <br />
system.gc() <br />
runtime.getruntime().gc() </p>
<p>20. string s = new string("xyz");创建了几个string object? <br />
　　两个对象，一个是&#8220;xyx&#8221;,一个是指向&#8220;xyx&#8221;的引用对象s。 </p>
<p>21. math.round(11.5)等于多少? math.round(-11.5)等于多少? <br />
　　math.round(11.5)返回（long）12，math.round(-11.5)返回（long）-11; </p>
<p>22. short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错? <br />
　　short s1 = 1; s1 = s1 + 1;有错，s1是short型，s1+1是int型,不能显式转化为short型。可修改为s1 =(short)(s1 + 1) 。short s1 = 1; s1 += 1正确。 </p>
<p>23. sleep() 和 wait() 有什么区别? 搞线程的最爱 <br />
　　sleep()方法是使线程停止一段时间的方法。在sleep 时间间隔期满后，线程不一定立即恢复执行。这是因为在那个时刻，其它线程可能正在运行而且没有被调度为放弃执行，除非(a)&#8220;醒来&#8221;的线程具有更高的优先级 (b)正在运行的线程因为其它原因而阻塞。 <br />
　　wait()是线程交互时，如果线程对一个同步对象x 发出一个wait()调用，该线程会暂停执行，被调对象进入等待状态，直到被唤醒或等待时间到。 </p>
<p>24. java有没有goto? <br />
　　goto?java中的保留字，现在没有在java中使用。 </p>
<p>25. 数组有没有length()这个方法? string有没有length()这个方法？ <br />
　　数组没有length()这个方法，有length的属性。 <br />
　　string有有length()这个方法。 </p>
<p>26. overload和override的区别。overloaded的方法是否可以改变返回值的类型? <br />
　　方法的重写overriding和重载overloading是java多态性的不同表现。重写overriding是父类与子类之间多态性的一种表现，重载overloading是一个类中多态性的一种表现。如果在子类中定义某方法与其父类有相同的名称和参数，我们说该方法被重写 (overriding)。子类的对象使用这个方法时，将调用子类中的定义，对它而言，父类中的定义如同被&#8220;屏蔽&#8221;了。如果在一个类中定义了多个同名的方法，它们或有不同的参数个数或有不同的参数类型，则称为方法的重载(overloading)。overloaded的方法是可以改变返回值的类型。 </p>
<p>27. set里的元素是不能重复的，那么用什么方法来区分重复与否呢? 是用==还是equals()? 它们有何区别? <br />
　　set里的元素是不能重复的，那么用iterator()方法来区分重复与否。equals()是判读两个set是否相等。 <br />
　　equals()和==方法决定引用值是否指向同一对象equals()在类中被覆盖，为的是当两个分离的对象的内容和类型相配的话，返回真值。</p>
<p>28. 最常见的runtime exception。&nbsp; <br />
ityException, SystemException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException&nbsp; </p>
<p>29. error和exception有什么区别?&nbsp; <br />
　　error 表示恢复不是不可能但很困难的情况下的一种严重问题。比如说内存溢出。不可能指望程序能处理这样的情况。&nbsp; <br />
　　exception 表示一种设计或实现问题。也就是说，它表示如果程序运行正常，从不会发生的情况。</p>
<p>30. List, Set, Map是否继承自Collection接口?&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp; List，Set是；Map不是&nbsp; </p>
<p>31. abstract class和interface有什么区别?&nbsp; <br />
　　声明方法的存在而不去实现它的类被叫做抽象类（abstract class），它用于要创建一个体现某些基本行为的类，并为该类声明方法，但不能在该类中实现该类的情况。不能创建abstract 类的实例。然而可以创建一个变量，其类型是一个抽象类，并让它指向具体子类的一个实例。不能有抽象构造函数或抽象静态方法。Abstract 类的子类为它们父类中的所有抽象方法提供实现，否则它们也是抽象类为。取而代之，在子类中实现该方法。知道其行为的其它类可以在类中实现这些方法。&nbsp; <br />
　　接口（interface）是抽象类的变体。在接口中，所有方法都是抽象的。多继承性可通过实现这样的接口而获得。接口中的所有方法都是抽象的，没有一个有程序体。接口只可以定义static final成员变量。接口的实现与子类相似，除了该实现类不能从接口定义中继承行为。当类实现特殊接口时，它定义（即将程序体给予）所有这种接口的方法。然后，它可以在实现了该接口的类的任何对象上调用接口的方法。由于有抽象类，它允许使用接口名作为引用变量的类型。通常的动态联编将生效。引用可以转换到接口类型或从接口类型转换，instanceof 运算符可以用来决定某对象的类是否实现了接口。&nbsp; </p>
<p>32. abstract的method是否可同时是static,是否可同时是native，是否可同时是synchronized?&nbsp; <br />
　　都不能&nbsp; </p>
<p>33. 接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)?&nbsp; <br />
　　接口可以继承接口。抽象类可以实现(implements)接口，抽象类可继承实体类，但前提是实体类必须有明确的构造函数。&nbsp; </p>
<p>34. 启动一个线程是用run()还是start()?&nbsp; <br />
　　启动一个线程是调用start()方法，使线程所代表的虚拟处理机处于可运行状态，这意味着它可以由JVM调度并执行。这并不意味着线程就会立即运行。run()方法可以产生必须退出的标志来停止一个线程。</p>
<p>35. 构造器Constructor是否可被override?&nbsp; <br />
　　构造器Constructor不能被继承，因此不能重写Overriding，但可以被重载Overloading。&nbsp; </p>
<p>36. 是否可以继承String类?&nbsp; <br />
　　String类是final类故不可以继承。&nbsp; </p>
<p>37. 当一个线程进入一个对象的一个synchronized方法后，其它线程是否可进入此对象的其它方法?&nbsp; <br />
　　不能，一个对象的一个synchronized方法只能由一个线程访问。&nbsp; </p>
<p>38. try {}里有一个return语句，那么紧跟在这个try后的finally {}里的code会不&nbsp; <br />
会被执行，什么时候被执行，在return前还是后?&nbsp; <br />
　　会执行，在return前执行。&nbsp; </p>
<p>39. 编程题: 用最有效率的方法算出2乘以8等於几?&nbsp; <br />
　　2 &lt;&lt; 3&nbsp; </p>
<p>40. 两个对象值相同(x.equals(y) == true)，但却可有不同的hash code，这句话对不对?&nbsp; <br />
　　不对，有相同的hash code。&nbsp; </p>
<p>41. 当一个对象被当作参数传递到一个方法后，此方法可改变这个对象的属性，并&nbsp; <br />
可返回变化后的结果，那么这里到底是值传递还是引用传递?&nbsp; <br />
　　是值传递。Java 编程语言只由值传递参数。当一个对象实例作为一个参数被传递到方法中时，参数的值就是对该对象的引用。对象的内容可以在被调用的方法中改变，但对象的引用是永远不会改变的。&nbsp; </p>
<p>42. swtich是否能作用在byte上，是否能作用在long上，是否能作用在String上?&nbsp; <br />
　　switch（expr1）中，expr1是一个整数表达式。因此传递给 switch 和 case 语句的参数应该是 int、 short、 char 或者 byte。long,string 都不能作用于swtich。&nbsp; </p>
<p>43. Hashtable和HashMap的异同。<br />
　　Hashtable继承自Dictionary类，而HashMap是Java1.2引进的Map interface的一个实现 。 <br />
　　HashMap允许将null作为一个entry的key或者value，而Hashtable不允许 <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 还有就是，HashMap把Hashtable的contains方法去掉了，改成containsvalue和<br />
containsKey。因为contains方法容易让人引起误解。<br />
最大的不同是，Hashtable的方法是Synchronize的，而HashMap不是，在多个线程访问Hashtable时，不需要自己为它的方法实现同步，而HashMap就必须为之提供外同步。&nbsp; <br />
&nbsp;&nbsp;&nbsp; Hashtable和HashMap采用的hash/rehash算法都大概一样，所以性能不会有很大的差异。</p>
<br />
<p>44.试举例说明一个典型的垃圾回收算法？ </p>
<p>45.请用java写二叉树算法，实现添加数据形成二叉树功能，并以先序的方式打印出来. </p>
<p>46.请写一个java程序实现线程连接池功能？ </p>
<p>47.给定一个C语言函数，要求实现在java类中进行调用。 </p>
<p>48、编一段代码，实现在控制台输入一组数字后，排序后在控制台输出； </p>
<p>49、列出某文件夹下的所有文件； </p>
<p>50、调用系统命令实现删除文件的操作； </p>
<p>51、实现从文件中一次读出一个字符的操作； </p>
<p>52、列出一些控制流程的方法； </p>
<p>53、多线程有哪些状态？ </p>
<p>54、编写了一个服务器端的程序实现在客户端输入字符然后在控制台上显示，直到输入"END"为止，让你写出客户端的程序； </p>
<p>55、作用域public,private,protected,以及不写时的区别 </p>
<p>　　答：区别如下： </p>
<p>　　作用域&nbsp;&nbsp; 当前类&nbsp;&nbsp; 同一package&nbsp;&nbsp; 子孙类&nbsp;&nbsp; 其他package </p>
<p>　　public&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730; </p>
<p>　　protected&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215; </p>
<p>　　friendly&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215; </p>
<p>　　private&nbsp;&nbsp;&nbsp; &#8730;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#215; </p>
<p>　　不写时默认为friendly </p>
<p>56、ArrayList和Vector的区别,HashMap和Hashtable的区别 </p>
<p>　　答：就ArrayList与Vector主要从二方面来说. </p>
<p>　　一.同步性:Vector是线程安全的，也就是说是同步的，而ArrayList是线程序不安全的，不是同步的 </p>
<p>　　二.数据增长:当需要增长时,Vector默认增长为原来一培，而ArrayList却是原来的一半就HashMap与HashTable主要从三方面来说。 </p>
<p>　　一.历史原因:Hashtable是基于陈旧的Dictionary类的，HashMap是Java 1.2引进的Map接口的一个实现 </p>
<p>　　二.同步性:Hashtable是线程安全的，也就是说是同步的，而HashMap是线程序不安全的，不是同步的 </p>
<p>　　三.值：只有HashMap可以让你将空值作为一个表的条目的key或value </p>
<p>57、char型变量中能不能存贮一个中文汉字?为什么? </p>
<p>　　答：是能够定义成为一个中文的，因为java中以unicode编码，一个char占16个字节，所以放一个中文是没问题的。</p>
<p>58、多线程有几种实现方法,都是什么?同步有几种实现方法,都是什么? </p>
<p>　　答：多线程有两种实现方法，分别是继承Thread类与实现Runnable接口<br />
　　同步的实现方面有两种，分别是synchronized,wait与notify </p>
<p>59、垃圾回收机制,如何优化程序? </p>
<p>　　希望大家补上，谢谢 </p>
<p>60、float型float f=3.4是否正确? </p>
<p>　　答:不正确。精度不准确,应该用强制类型转换，如下所示：float f=(float)3.4 </p>
<p>61、介绍JAVA中的Collection FrameWork(包括如何写自己的数据结构)? </p>
<p>　　答：Collection FrameWork如下： </p>
<p>Collection </p>
<p>├List </p>
<p>│├LinkedList </p>
<p>│├ArrayList </p>
<p>│└Vector </p>
<p>│　└Stack </p>
<p>└Set </p>
<p>Map </p>
<p>├Hashtable </p>
<p>├HashMap </p>
<p>└WeakHashMap </p>
<p>　　Collection是最基本的集合接口，一个Collection代表一组Object，即Collection的元素（Elements） </p>
<p>　　Map提供key到value的映射 </p>
<p>62、Java中异常处理机制，事件机制？ </p>
<p>63、抽象类与接口？ </p>
<p>　　答：抽象类与接口都用于抽象，但是抽象类(JAVA中)可以有自己的部分实现，而接口则完全是一个标识(同时有多重继承的功能)。 </p>
<p>64、JAVA中的多态与继承？ </p>
<p>　　希望大家补上，谢谢 </p>
<p>65、&amp;和&amp;&amp;的区别？</p>
<p>&nbsp;&nbsp;&nbsp; &amp;是位运算符，&amp;&amp;是逻辑运算符</p>
<p>66，编程题: 写一个Singleton出来。 </p>
<p>　　Singleton模式主要作用是保证在Java应用程序中，一个类Class只有一个实例存在。 </p>
<p>　　一般Singleton模式通常有几种种形式： </p>
<p>　　第一种形式：定义一个类，它的构造函数为private的，它有一个static的private的该类变量，在类初始化时实例话，通过一个public的getInstance方法获取对它的引用,继而调用其中的方法。 </p>
<p>　　public class Singleton { </p>
<p>　　private Singleton(){} </p>
<p>　　//在自己内部定义自己一个实例，是不是很奇怪？ </p>
<p>　　//注意这是private 只供内部调用 </p>
<p>　　private static Singleton instance = new Singleton(); </p>
<p>　　//这里提供了一个供外部访问本class的静态方法，可以直接访问　　 </p>
<p>　　public static Singleton getInstance() { </p>
<p>　　　　return instance; 　　 </p>
<p>　　 } </p>
<p>　　} </p>
<p>　　第二种形式： </p>
<p>　　public class Singleton { </p>
<p>　　private static Singleton instance = null; </p>
<p>　　public static synchronized Singleton getInstance() { </p>
<p>　　//这个方法比上面有所改进，不用每次都进行生成对象，只是第一次　　　 　 </p>
<p>　　//使用时生成实例，提高了效率！ </p>
<p>　　if (instance==null) </p>
<p>　　　　instance＝new Singleton(); </p>
<p>&nbsp;&nbsp;&nbsp; return instance; 　　</p>
<p>&nbsp;&nbsp;&nbsp; } </p>
<p>　　} </p>
<p>　　其他形式： </p>
<p>　　定义一个类，它的构造函数为private的，所有方法为static的。 </p>
<p>　　一般认为第一种形式要更加安全些 </p>
<p>67.描述一下JVM加载class文件的原理机制? </p>
<img src ="http://www.blogjava.net/bily/aggbug/81603.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 20:48 <a href="http://www.blogjava.net/bily/articles/81603.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>著名软件公司笔试题目</title><link>http://www.blogjava.net/bily/articles/81602.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 12:45:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81602.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81602.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81602.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81602.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81602.html</trackback:ping><description><![CDATA[
		<p>JAVA华为面试题</p>
		<p>JAVA方面<br />1 面向对象的特征有哪些方面 </p>
		<p>2 String是最基本的数据类型吗?</p>
		<p>3 int 和 Integer 有什么区别</p>
		<p>4 String 和StringBuffer的区别</p>
		<p>5运行时异常与一般异常有何异同？<br />异常表示程序运行过程中可能出现的非正常状态，运行时异常表示虚拟机的通常操作中可能遇到的异常，是一种常见运行错误。java编译器要求方法必须声明抛出可能发生的非运行时异常，但是并不要求必须声明抛出未被捕获的运行时异常。</p>
		<p>6 说出一些常用的类，包,接口，请各举5个</p>
		<p>7 说出ArrayList,Vector, LinkedList的存储性能和特性<br />ArrayList和Vector都是使用数组方式存储数据，此数组元素数大于实际存储的数据以便增加和插入元素，它们都允许直接按序号索引元素，但是插入元素要涉及数组元素移动等内存操作，所以索引数据快而插入数据慢，Vector由于使用了synchronized方法（线程安全），通常性能上较ArrayList差，而LinkedList使用双向链表实现存储，按序号索引数据需要进行前向或后向遍历，但是插入数据时只需要记录本项的前后项即可，所以插入速度较快。</p>
		<p>8设计4个线程，其中两个线程每次对j增加1，另外两个线程对j每次减少1。写出程序。<br />以下程序使用内部类实现线程，对j增减的时候没有考虑顺序问题。<br />public class ThreadTest1{<br />private int j;<br />public static void main(String args[]){<br />  ThreadTest1 tt=new ThreadTest1();<br />  Inc inc=tt.new Inc();<br />  Dec dec=tt.new Dec();<br />  for(int i=0;i&lt;2;i++){<br />    Thread t=new Thread(inc);<br />    t.start();<br />    t=new Thread(dec);<br />    t.start();<br />  }<br />}<br />private synchronized void inc(){<br />  j++;<br />  System.out.println(Thread.currentThread().getName()+"-inc:"+j);<br />}<br />private synchronized void dec(){<br />  j--;<br />  System.out.println(Thread.currentThread().getName()+"-dec:"+j);<br />}</p>
		<p>class Inc implements Runnable{<br />  public void run(){<br />    for(int i=0;i&lt;100;i++){<br />    inc();<br />    }<br />  }<br />}<br />class Dec implements Runnable{<br />  public void run(){<br />    for(int i=0;i&lt;100;i++){<br />    dec();<br />    }<br />  }<br />}<br />}</p>
		<p>9． JSP的内置对象及方法。<br />request request表示HttpServletRequest对象。它包含了有关浏览器请求的信息，并且提供了几个用于获取cookie, header, 和session数据的有用的方法。 </p>
		<p>response response表示HttpServletResponse对象，并提供了几个用于设置送回 浏览器的响应的方法（如cookies,头信息等） </p>
		<p>out out 对象是javax.jsp.JspWriter的一个实例，并提供了几个方法使你能用于向浏览器回送输出结果。 </p>
		<p>pageContext pageContext表示一个javax.servlet.jsp.PageContext对象。它是用于方便存取各种范围的名字空间、servlet相关的对象的API，并且包装了通用的servlet相关功能的方法。 </p>
		<p>session session表示一个请求的javax.servlet.http.HttpSession对象。Session可以存贮用户的状态信息 </p>
		<p>application applicaton 表示一个javax.servle.ServletContext对象。这有助于查找有关servlet引擎和servlet环境的信息 </p>
		<p>config config表示一个javax.servlet.ServletConfig对象。该对象用于存取servlet实例的初始化参数。 </p>
		<p>page page表示从该页面产生的一个servlet实例</p>
		<p>10.用socket通讯写出客户端和服务器端的通讯，要求客户发送数据后能够回显相同的数据。<br />参见课程中socket通讯例子。</p>
		<p>11说出Servlet的生命周期，并说出Servlet和CGI的区别。<br />Servlet被服务器实例化后，容器运行其init方法，请求到达时运行其service方法，service方法自动派遣运行与请求对应的doXXX方法（doGet，doPost）等，当服务器决定将实例销毁的时候调用其destroy方法。<br />与cgi的区别在于servlet处于服务器进程中，它通过多线程方式运行其service方法，一个实例可以服务于多个请求，并且其实例一般不会销毁，而CGI对每个请求都产生新的进程，服务完成后就销毁，所以效率上低于servlet。</p>
		<p>12.EJB是基于哪些技术实现的?并说出SessionBean和EntityBean的区别，StatefulBean和StatelessBean的区别。</p>
		<p>13．EJB包括（SessionBean,EntityBean）说出他们的生命周期，及如何管理事务的？</p>
		<p>14．说出数据连接池的工作机制是什么?</p>
		<p>15同步和异步有和异同，在什么情况下分别使用他们？举例说明。</p>
		<p>16应用服务器有那些？</p>
		<p>17你所知道的集合类都有哪些？主要方法？</p>
		<p>18给你一个:驱动程序A,数据源名称为B,用户名称为C,密码为D,数据库表为T，请用JDBC检索出表T的所有数据。</p>
		<p>19．说出在JSP页面里是怎么分页的?<br />页面需要保存以下参数：<br />总行数：根据sql语句得到总行数<br />每页显示行数：设定值<br />当前页数：请求参数<br />页面根据当前页数和每页行数计算出当前页第一行行数，定位结果集到此行，对结果集取出每页显示行数的行即可。</p>
		<p>数据库方面：</p>
		<p>1. 存储过程和函数的区别<br />存储过程是用户定义的一系列sql语句的集合，涉及特定表或其它对象的任务，用户可以调用存储过程，而函数通常是数据库已定义的方法，它接收参数并返回某种类型的值并且不涉及特定用户表。</p>
		<p>2. 事务是什么？<br />事务是作为一个逻辑单元执行的一系列操作，一个逻辑工作单元必须有四个属性，称为 ACID（原子性、一致性、隔离性和持久性）属性，只有这样才能成为一个事务：<br />原子性<br />事务必须是原子工作单元；对于其数据修改，要么全都执行，要么全都不执行。<br />一致性<br />事务在完成时，必须使所有的数据都保持一致状态。在相关数据库中，所有规则都必须应用于事务的修改，以保持所有数据的完整性。事务结束时，所有的内部数据结构（如 B 树索引或双向链表）都必须是正确的。<br />隔离性<br />由并发事务所作的修改必须与任何其它并发事务所作的修改隔离。事务查看数据时数据所处的状态，要么是另一并发事务修改它之前的状态，要么是另一事务修改它之后的状态，事务不会查看中间状态的数据。这称为可串行性，因为它能够重新装载起始数据，并且重播一系列事务，以使数据结束时的状态与原始事务执行的状态相同。<br />持久性<br />事务完成之后，它对于系统的影响是永久性的。该修改即使出现系统故障也将一直保持。</p>
		<p>3. 游标的作用？如何知道游标已经到了最后？<br />游标用于定位结果集的行，通过判断全局变量@@FETCH_STATUS可以判断是否到了最后，通常此变量不等于0表示出错或到了最后。</p>
		<p>4. 触发器分为事前触发和事后触发，这两种触发有和区别。语句级触发和行级触发有何区别。<br />事前触发器运行于触发事件发生之前，而事后触发器运行于触发事件发生之后。通常事前触发器可以获取事件之前和新的字段值。<br />语句级触发器可以在语句执行前或后执行，而行级触发在触发器所影响的每一行触发一次。</p>
		<p>
				<br />中远面试题</p>
		<p>一、JAVA</p>
		<p>1、面向对象的三个基本特征</p>
		<p>2、方法重载和方法重写的概念和区别</p>
		<p>3、接口和内部类、抽象类的特性</p>
		<p>4、文件读写的基本类</p>
		<p>5、串行化的注意事项以及如何实现串行化</p>
		<p>6、线程的基本概念、线程的基本状态以及状态之间的关系</p>
		<p>7、线程的同步、如何实现线程的同步</p>
		<p>8、几种常用的数据结构及内部实现原理。</p>
		<p>9、Socket通信(TCP、UDP区别及Java实现方式)</p>
		<p>10、Java的事件委托机制和垃圾回收机制</p>
		<p>11、JDBC调用数据库的基本步骤</p>
		<p>12、解析XML文件的几种方式和区别</p>
		<p>13、Java四种基本权限的定义</p>
		<p>14、Java的国际化</p>
		<p>二、JSP</p>
		<p>1、至少要能说出7个隐含对象以及他们的区别</p>
		<p>2、forward 和redirect的区别</p>
		<p>3、JSP的常用指令</p>
		<p>三、servlet</p>
		<p>1、什么情况下调用doGet()和doPost()？</p>
		<p>2、servlet的init()方法和service()方法的区别</p>
		<p>3、servlet的生命周期</p>
		<p>4、如何现实servlet的单线程模式</p>
		<p>5、servlet的配置</p>
		<p>6、四种会话跟踪技术</p>
		<p>四、EJB</p>
		<p>1、EJB容器提供的服务<br />主要提供声明周期管理、代码产生、持续性管理、安全、事务管理、锁和并发行管理等服务。</p>
		<p>2、EJB的角色和三个对象<br />EJB角色主要包括Bean开发者 应用组装者 部署者 系统管理员 EJB容器提供者 EJB服务器提供者<br />三个对象是Remote（Local）接口、Home（LocalHome）接口，Bean类</p>
		<p>3、EJB的几种类型<br />会话（Session）Bean ，实体（Entity）Bean 消息驱动的（Message Driven）Bean<br />会话Bean又可分为有状态（Stateful）和无状态（Stateless）两种<br />实体Bean可分为Bean管理的持续性（BMP）和容器管理的持续性（CMP）两种</p>
		<p>4、bean 实例的生命周期<br />对于Stateless Session Bean、Entity Bean、Message Driven Bean一般存在缓冲池管理，而对于Entity Bean和Statefull Session Bean存在Cache管理，通常包含创建实例，设置上下文、创建EJB Object（create）、业务方法调用、remove等过程，对于存在缓冲池管理的Bean，在create之后实例并不从内存清除，而是采用缓冲池调度机制不断重用实例，而对于存在Cache管理的Bean则通过激活和去激活机制保持Bean的状态并限制内存中实例数量。</p>
		<p>5、激活机制<br />以Statefull Session Bean 为例：其Cache大小决定了内存中可以同时存在的Bean实例的数量，根据MRU或NRU算法，实例在激活和去激活状态之间迁移，激活机制是当客户端调用某个EJB实例业务方法时，如果对应EJB Object发现自己没有绑定对应的Bean实例则从其去激活Bean存储中（通过序列化机制存储实例）回复（激活）此实例。状态变迁前会调用对应的ejbActive和ejbPassivate方法。</p>
		<p>6、remote接口和home接口主要作用<br />remote接口定义了业务方法，用于EJB客户端调用业务方法<br />home接口是EJB工厂用于创建和移除查找EJB实例</p>
		<p>7、客服端调用EJB对象的几个基本步骤<br />(1)设置JNDI服务工厂以及JNDI服务地址系统属性<br />(2)查找Home接口<br />(3)从Home接口调用Create方法创建Remote接口<br />(4)通过Remote接口调用其业务方法</p>
		<p>五、数据库</p>
		<p>1、存储过程的编写</p>
		<p>2、基本的SQL语句</p>
		<p>六、weblogic</p>
		<p>1、 如何给weblogic指定大小的内存? <br />在启动Weblogic的脚本中（位于所在Domian对应服务器目录下的startServerName），增加set MEM_ARGS=-Xms32m -Xmx200m，可以调整最小内存为32M，最大200M</p>
		<p>2、 如何设定的weblogic的热启动模式(开发模式)与产品发布模式?<br />可以在管理控制台中修改对应服务器的启动模式为开发或产品模式之一。或者修改服务的启动文件或者commenv文件，增加set PRODUCTION_MODE=true。</p>
		<p>3、 如何启动时不需输入用户名与密码?<br />修改服务启动文件，增加 WLS_USER和WLS_PW项。也可以在boot.properties文件中增加加密过的用户名和密码.</p>
		<p>4、 在weblogic管理制台中对一个应用域(或者说是一个网站,Domain)进行jms及ejb或连接池等相关信息进行配置后,实际保存在什么文件中?<br />保存在此Domain的config.xml文件中，它是服务器的核心配置文件。</p>
		<p>5、 说说weblogic中一个Domain的缺省目录结构?比如要将一个简单的helloWorld.jsp放入何目录下,然的在浏览器上就可打入http://主机:端口号//helloword.jsp就可以看到运行结果了? 又比如这其中用到了一个自己写的javaBean该如何办?<br />Domain目录\服务器目录\applications，将应用目录放在此目录下将可以作为应用访问，如果是Web应用，应用目录需要满足Web应用目录要求，jsp文件可以直接放在应用目录中，Javabean需要放在应用目录的WEB-INF目录的classes目录中，设置服务器的缺省应用将可以实现在浏览器上无需输入应用名。</p>
		<p>6、 如何查看在weblogic中已经发布的EJB?<br />可以使用管理控制台，在它的Deployment中可以查看所有已发布的EJB </p>
		<p>7、 如何在weblogic中进行ssl配置与客户端的认证配置或说说j2ee(标准)进行ssl的配置<br />缺省安装中使用DemoIdentity.jks和DemoTrust.jks KeyStore实现SSL，需要配置服务器使用Enable SSL，配置其端口，在产品模式下需要从CA获取私有密钥和数字证书，创建identity和trust keystore，装载获得的密钥和数字证书。可以配置此SSL连接是单向还是双向的。</p>
		<p>8、在weblogic中发布ejb需涉及到哪些配置文件<br />不同类型的EJB涉及的配置文件不同，都涉及到的配置文件包括ejb-jar.xml,weblogic-ejb-jar.xmlCMP实体Bean一般还需要weblogic-cmp-rdbms-jar.xml</p>
		<p>9、EJB需直接实现它的业务接口或Home接口吗,请简述理由.<br />远程接口和Home接口不需要直接实现，他们的实现代码是由服务器产生的，程序运行中对应实现类会作为对应接口类型的实例被使用。</p>
		<p>10、说说在weblogic中开发消息Bean时的persistent与non-persisten的差别<br />persistent方式的MDB可以保证消息传递的可靠性,也就是如果EJB容器出现问题而JMS服务器依然会将消息在此MDB可用的时候发送过来，而non－persistent方式的消息将被丢弃。</p>
		<p>11、说说你所熟悉或听说过的j2ee中的几种常用模式?及对设计模式的一些看法<br />Session Facade Pattern：使用SessionBean访问EntityBean<br />Message Facade Pattern：实现异步调用<br />EJB Command Pattern：使用Command JavaBeans取代SessionBean，实现轻量级访问<br />Data Transfer Object Factory：通过DTO Factory简化EntityBean数据提供特性<br />Generic Attribute Access：通过AttibuteAccess接口简化EntityBean数据提供特性<br />Business Interface：通过远程（本地）接口和Bean类实现相同接口规范业务逻辑一致性<br />ＥＪＢ架构的设计好坏将直接影响系统的性能、可扩展性、可维护性、组件可重用性及开发效率。项目越复杂，项目队伍越庞大则越能体现良好设计的重要性</p>
<img src ="http://www.blogjava.net/bily/aggbug/81602.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 20:45 <a href="http://www.blogjava.net/bily/articles/81602.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java面试题集（三）</title><link>http://www.blogjava.net/bily/articles/81601.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 12:40:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81601.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81601.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81601.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81601.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81601.html</trackback:ping><description><![CDATA[
		<p>基础知识：<br />1.C++或Java中的异常处理机制的简单原理和应用。<br />当JAVA程序违反了JAVA的语义规则时，JAVA虚拟机就会将发生的错误表示为一个异常。违反语义规则包括2种情况。一种是JAVA类库内置的语义检查。例如数组下标越界,会引发IndexOutOfBoundsException;访问null的对象时会引发NullPointerException。另一种情况就是JAVA允许程序员扩展这种语义检查，程序员可以创建自己的异常，并自由选择在何时用throw关键字引发异常。所有的异常都是java.lang.Thowable的子类。</p>
		<p>2. Java的接口和C++的虚类的相同和不同处。<br />由于Java不支持多继承，而有可能某个类或对象要使用分别在几个类或对象里面的方法或属性，现有的单继承机制就不能满足要求。与继承相比，接口有更高的灵活性，因为接口中没有任何实现代码。当一个类实现了接口以后，该类要实现接口里面所有的方法和属性，并且接口里面的属性在默认状态下面都是public static,所有方法默认情况下是public.一个类可以实现多个接口。</p>
		<p>3. 垃圾回收的优点和原理。并考虑2种回收机制。<br />Java语言中一个显著的特点就是引入了垃圾回收机制，使c++程序员最头疼的内存管理的问题迎刃而解，它使得Java程序员在编写程序的时候不再需要考虑内存管理。由于有个垃圾回收机制，Java中的对象不再有“作用域”的概念，只有对象的引用才有“作用域”。垃圾回收可以有效的防止内存泄露，有效的使用可以使用的内存。垃圾回收器通常是作为一个单独的低级别的线程运行，不可预知的情况下对内存堆中已经死亡的或者长时间没有使用的对象进行清楚和回收，程序员不能实时的调用垃圾回收器对某个对象或所有对象进行垃圾回收。回收机制有分代复制垃圾回收和标记垃圾回收，增量垃圾回收。</p>
		<p>4. 请说出你所知道的线程同步的方法。<br />wait():使一个线程处于等待状态，并且释放所持有的对象的lock。<br />sleep():使一个正在运行的线程处于睡眠状态，是一个静态方法，调用此方法要捕捉InterruptedException异常。<br />notify():唤醒一个处于等待状态的线程，注意的是在调用此方法的时候，并不能确切的唤醒某一个等待状态的线程，而是由JVM确定唤醒哪个线程，而且不是按优先级。<br />Allnotity():唤醒所有处入等待状态的线程，注意并不是给所有唤醒线程一个对象的锁，而是让它们竞争。</p>
		<p>5. 请讲一讲析构函数和虚函数的用法和作用。</p>
		<p>6. Error与Exception有什么区别？<br />Error表示系统级的错误和程序不必处理的异常，<br />Exception表示需要捕捉或者需要程序进行处理的异常。</p>
		<p>7. 在java中一个类被声明为final类型，表示了什么意思？<br />表示该类不能被继承，是顶级类。</p>
		<p>8. 描述一下你最常用的编程风格。 </p>
		<p>9. heap和stack有什么区别。<br />栈是一种线形集合，其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进行处理。<br />堆是栈的一个组成元素</p>
		<p>10. 如果系统要使用超大整数（超过long长度范围），请你设计一个数据结构来存储这种超大型数字以及设计一种算法来实现超大整数加法运算）。<br />public class BigInt()<br />{<br />int[] ArrOne = new ArrOne[1000];<br />String intString="";<br />public int[] Arr(String s)<br />{<br />intString = s;<br />for(int i=0;i&lt;ArrOne.leght;i++)<br />{</p>
		<p>11. 如果要设计一个图形系统，请你设计基本的图形元件(Point,Line,Rectangle,Triangle)的简单实现</p>
		<p>12，谈谈final, finally, finalize的区别。 <br />　　final?修饰符（关键字）如果一个类被声明为final，意味着它不能再派生出新的子类，不能作为父类被继承。因此一个类不能既被声明为 abstract的，又被声明为final的。将变量或方法声明为final，可以保证它们在使用中不被改变。被声明为final的变量必须在声明时给定初值，而在以后的引用中只能读取，不可修改。被声明为final的方法也同样只能使用，不能重载。 <br />　　finally?再异常处理时提供 finally 块来执行任何清除操作。如果抛出一个异常，那么相匹配的 catch 子句就会执行，然后控制就会进入 finally 块（如果有的话）。<br />　　finalize?方法名。Java 技术允许使用 finalize() 方法在垃圾收集器将对象从内存中清除出去之前做必要的清理工作。这个方法是由垃圾收集器在确定这个对象没有被引用时对这个对象调用的。它是在 Object 类中定义的，因此所有的类都继承了它。子类覆盖 finalize() 方法以整理系统资源或者执行其他清理工作。finalize() 方法是在垃圾收集器删除对象之前对这个对象调用的。 </p>
		<p>13，Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类，是否可以implements(实现)interface(接口)? <br />　　匿名的内部类是没有名字的内部类。不能extends(继承) 其它类，但一个内部类可以作为一个接口，由另一个内部类实现。 </p>
		<p>14，Static Nested Class 和 Inner Class的不同，说得越多越好(面试题有的很笼统)。<br />　　Nested Class （一般是C++的说法），Inner Class (一般是JAVA的说法)。Java内部类与C++嵌套类最大的不同就在于是否有指向外部的引用上。具体可见http: //www.frontfree.net/articles/services/view.asp?id=704&amp;page=1 <br />　　注： 静态内部类（Inner Class）意味着1创建一个static内部类的对象，不需要一个外部类对象，2不能从一个static内部类的一个对象访问一个外部类对象 <br />第四，&amp;和&amp;&amp;的区别。<br />　　&amp;是位运算符。&amp;&amp;是布尔逻辑运算符。 </p>
		<p>15，HashMap和Hashtable的区别。<br />　　都属于Map接口的类，实现了将惟一键映射到特定的值上。<br />　　HashMap 类没有分类或者排序。它允许一个 null 键和多个 null 值。<br />　　Hashtable 类似于 HashMap，但是不允许 null 键和 null 值。它也比 HashMap 慢，因为它是同步的。 </p>
		<p>16，Collection 和 Collections的区别。<br />　　Collections是个java.util下的类，它包含有各种有关集合操作的静态方法。<br />　　Collection是个java.util下的接口，它是各种集合结构的父接口。 </p>
		<p>17，什么时候用assert。<br />　　断言是一个包含布尔表达式的语句，在执行这个语句时假定该表达式为 true。如果表达式计算为 false，那么系统会报告一个 Assertionerror。它用于调试目的：<br />assert(a &gt; 0); // throws an Assertionerror if a &lt;= 0 <br />断言可以有两种形式：<br />assert Expression1 ; <br />assert Expression1 : Expression2 ; <br />　　Expression1 应该总是产生一个布尔值。<br />　　Expression2 可以是得出一个值的任意表达式。这个值用于生成显示更多调试信息的 String 消息。<br />　　断言在默认情况下是禁用的。要在编译时启用断言，需要使用 source 1.4 标记：<br />　　javac -source 1.4 Test.java <br />　　要在运行时启用断言，可使用 -enableassertions 或者 -ea 标记。<br />　　要在运行时选择禁用断言，可使用 -da 或者 -disableassertions 标记。<br />　　要系统类中启用断言，可使用 -esa 或者 -dsa 标记。还可以在包的基础上启用或者禁用断言。 <br />　　可以在预计正常情况下不会到达的任何位置上放置断言。断言可以用于验证传递给私有方法的参数。不过，断言不应该用于验证传递给公有方法的参数，因为不管是否启用了断言，公有方法都必须检查其参数。不过，既可以在公有方法中，也可以在非公有方法中利用断言测试后置条件。另外，断言不应该以任何方式改变程序的状态。 </p>
		<p>18，GC是什么? 为什么要有GC? (基础)。<br />　　GC是垃圾收集器。Java 程序员不用担心内存管理，因为垃圾收集器会自动进行管理。要请求垃圾收集，可以调用下面的方法之一：<br />System.gc() <br />Runtime.getRuntime().gc() </p>
		<p>19，String s = new String("xyz");创建了几个String Object? <br />　　两个对象，一个是“xyx”,一个是指向“xyx”的引用对象s。 </p>
		<p>20，Math.round(11.5)等於多少? Math.round(-11.5)等於多少? <br />　　Math.round(11.5)返回（long）12，Math.round(-11.5)返回（long）-11;</p>
		<p>21，short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错? <br />　　short s1 = 1; s1 = s1 + 1;有错，s1是short型，s1+1是int型,不能显式转化为short型。可修改为s1 =(short)(s1 + 1) 。short s1 = 1; s1 += 1正确。 </p>
		<p>22，sleep() 和 wait() 有什么区别? 搞线程的最爱<br />　　sleep()方法是使线程停止一段时间的方法。在sleep 时间间隔期满后，线程不一定立即恢复执行。这是因为在那个时刻，其它线程可能正在运行而且没有被调度为放弃执行，除非(a)“醒来”的线程具有更高的优先级 (b)正在运行的线程因为其它原因而阻塞。<br />　　wait()是线程交互时，如果线程对一个同步对象x 发出一个wait()调用，该线程会暂停执行，被调对象进入等待状态，直到被唤醒或等待时间到。 </p>
		<p>23，Java有没有goto? <br />　　Goto?java中的保留字，现在没有在java中使用。 </p>
		<p>24，数组有没有length()这个方法? String有没有length()这个方法？<br />　　数组没有length()这个方法，有length的属性。<br />　　String有有length()这个方法。 </p>
		<p>25，Overload和Override的区别。Overloaded的方法是否可以改变返回值的类型? <br />　　方法的重写Overriding和重载Overloading是Java多态性的不同表现。重写Overriding是父类与子类之间多态性的一种表现，重载Overloading是一个类中多态性的一种表现。如果在子类中定义某方法与其父类有相同的名称和参数，我们说该方法被重写 (Overriding)。子类的对象使用这个方法时，将调用子类中的定义，对它而言，父类中的定义如同被“屏蔽”了。如果在一个类中定义了多个同名的方法，它们或有不同的参数个数或有不同的参数类型，则称为方法的重载(Overloading)。Overloaded的方法是可以改变返回值的类型。 </p>
		<p>26，Set里的元素是不能重复的，那么用什么方法来区分重复与否呢? 是用==还是equals()? 它们有何区别? <br />　　Set里的元素是不能重复的，那么用iterator()方法来区分重复与否。equals()是判读两个Set是否相等。<br />　　equals()和==方法决定引用值是否指向同一对象equals()在类中被覆盖，为的是当两个分离的对象的内容和类型相配的话，返回真值。 </p>
		<p>27，给我一个你最常见到的runtime exception。<br />ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, <br />ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFORMatException, SecurityException, SystemException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException </p>
		<p>28，error和exception有什么区别? <br />　　error 表示恢复不是不可能但很困难的情况下的一种严重问题。比如说内存溢出。不可能指望程序能处理这样的情况。<br />　　exception 表示一种设计或实现问题。也就是说，它表示如果程序运行正常，从不会发生的情况。 </p>
		<p>29，List, Set, Map是否继承自Collection接口? <br />List，Set是 <br />Map不是 </p>
		<p>30，abstract class和interface有什么区别? <br />　　声明方法的存在而不去实现它的类被叫做抽象类（abstract class），它用于要创建一个体现某些基本行为的类，并为该类声明方法，但不能在该类中实现该类的情况。不能创建abstract 类的实例。然而可以创建一个变量，其类型是一个抽象类，并让它指向具体子类的一个实例。不能有抽象构造函数或抽象静态方法。Abstract 类的子类为它们父类中的所有抽象方法提供实现，否则它们也是抽象类为。取而代之，在子类中实现该方法。知道其行为的其它类可以在类中实现这些方法。<br />　　接口（interface）是抽象类的变体。在接口中，所有方法都是抽象的。多继承性可通过实现这样的接口而获得。接口中的所有方法都是抽象的，没有一个有程序体。接口只可以定义static final成员变量。接口的实现与子类相似，除了该实现类不能从接口定义中继承行为。当类实现特殊接口时，它定义（即将程序体给予）所有这种接口的方法。然后，它可以在实现了该接口的类的任何对象上调用接口的方法。由于有抽象类，它允许使用接口名作为引用变量的类型。通常的动态联编将生效。引用可以转换到接口类型或从接口类型转换，instanceof 运算符可以用来决定某对象的类是否实现了接口。</p>
		<p>31，abstract的method是否可同时是static,是否可同时是native，是否可同时是synchronized? <br />　　都不能 </p>
		<p>32，接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)? <br />　　接口可以继承接口。抽象类可以实现(implements)接口，抽象类是否可继承实体类，但前提是实体类必须有明确的构造函数。 </p>
		<p>33，启动一个线程是用run()还是start()? <br />　　启动一个线程是调用start()方法，使线程所代表的虚拟处理机处于可运行状态，这意味着它可以由JVM调度并执行。这并不意味着线程就会立即运行。run()方法可以产生必须退出的标志来停止一个线程。 </p>
		<p>34，构造器Constructor是否可被override? <br />　　构造器Constructor不能被继承，因此不能重写Overriding，但可以被重载Overloading。 </p>
		<p>35，是否可以继承String类? <br />　　String类是final类故不可以继承。 </p>
		<p>36，当一个线程进入一个对象的一个synchronized方法后，其它线程是否可进入此对象的其它方法? <br />　　不能，一个对象的一个synchronized方法只能由一个线程访问。 </p>
		<p>37，try {}里有一个return语句，那么紧跟在这个try后的finally {}里的code会不会被执行，什么时候被执行，在return前还是后? <br />　　会执行，在return前执行。 </p>
		<p>38，编程题: 用最有效率的方法算出2乘以8等於几? <br />　　有C背景的程序员特别喜欢问这种问题。 <br />　　2 &lt;&lt; 3 </p>
		<p>39，两个对象值相同(x.equals(y) == true)，但却可有不同的hash code，这句话对不对? <br />　　不对，有相同的hash code。 </p>
		<p>40，当一个对象被当作参数传递到一个方法后，此方法可改变这个对象的属性，并可返回变化后的结果，那么这里到底是值传递还是引用传递? <br />　　是值传递。Java 编程语言只由值传递参数。当一个对象实例作为一个参数被传递到方法中时，参数的值就是对该对象的引用。对象的内容可以在被调用的方法中改变，但对象的引用是永远不会改变的。</p>
		<p>41，swtich是否能作用在byte上，是否能作用在long上，是否能作用在String上?<br />　　switch（expr1）中，expr1是一个整数表达式。因此传递给 switch 和 case 语句的参数应该是 int、 short、 char 或者 byte。long,string 都不能作用于swtich。 <br />42，编程题: 写一个Singleton出来。<br />　　Singleton模式主要作用是保证在Java应用程序中，一个类Class只有一个实例存在。<br />　　一般Singleton模式通常有几种种形式：<br />　　第一种形式：定义一个类，它的构造函数为private的，它有一个static的private的该类变量，在类初始化时实例话，通过一个public的getInstance方法获取对它的引用,继而调用其中的方法。<br />public class Singleton { <br />　　private Singleton(){} <br />　　//在自己内部定义自己一个实例，是不是很奇怪？ <br />　　//注意这是private 只供内部调用 <br />　　private static Singleton instance = new Singleton(); <br />　　//这里提供了一个供外部访问本class的静态方法，可以直接访问　　 <br />　　public static Singleton getInstance() { <br />　　　　return instance; 　　 <br />　　 } <br />} </p>
		<p>　　第二种形式：<br />public class Singleton { <br />　　private static Singleton instance = null; <br />　　public static synchronized Singleton getInstance() { <br />　　//这个方法比上面有所改进，不用每次都进行生成对象，只是第一次　　　 　 <br />　　//使用时生成实例，提高了效率！ <br />　　if (instance==null) <br />　　　　instance＝new Singleton(); <br />return instance; 　　} <br />} <br />其他形式：<br />　　定义一个类，它的构造函数为private的，所有方法为static的。<br />　　一般认为第一种形式要更加安全些 <br />　　Hashtable和HashMap <br />　　Hashtable继承自Dictionary类，而HashMap是Java1.2引进的Map interface的一个实现 <br />　　HashMap允许将null作为一个entry的key或者value，而Hashtable不允许 <br />　　还有就是，HashMap把Hashtable的contains方法去掉了，改成containsvalue和containsKey。因为contains方法容易让人引起误解。 <br />　　最大的不同是，Hashtable的方法是Synchronize的，而HashMap不是，在 <br />多个线程访问Hashtable时，不需要自己为它的方法实现同步，而HashMap <br />就必须为之提供外同步。 <br />Hashtable和HashMap采用的hash/rehash算法都大概一样，所以性能不会有很大的差异。<br />43.描述一下JVM加载class文件的原理机制?<br />44.试举例说明一个典型的垃圾回收算法？ <br />45.请用java写二叉树算法，实现添加数据形成二叉树功能，并以先序的方式打印出来. <br />46.请写一个java程序实现线程连接池功能？ <br />47.给定一个C语言函数，要求实现在java类中进行调用。<br />48、编一段代码，实现在控制台输入一组数字后，排序后在控制台输出；<br />49、列出某文件夹下的所有文件；<br />50、调用系统命令实现删除文件的操作；<br />51、实现从文件中一次读出一个字符的操作；<br />52、列出一些控制流程的方法；<br />53、多线程有哪些状态？<br />54、编写了一个服务器端的程序实现在客户端输入字符然后在控制台上显示，直到输入"END"为止，让你写出客户端的程序；<br />55、作用域public,private,protected,以及不写时的区别 <br />答：区别如下： <br />作用域 当前类 同一package 子孙类 其他package <br />public √ √ √ √ <br />protected √ √ √ × <br />friendly √ √ × × <br />private √ × × × <br />不写时默认为friendly <br />56、ArrayList和Vector的区别,HashMap和Hashtable的区别 <br />答：就ArrayList与Vector主要从二方面来说. <br />一.同步性:Vector是线程安全的，也就是说是同步的，而ArrayList是线程序不安全的，不是同步的 <br />二.数据增长:当需要增长时,Vector默认增长为原来一培，而ArrayList却是原来的一半 <br />就HashMap与HashTable主要从三方面来说。 <br />一.历史原因:Hashtable是基于陈旧的Dictionary类的，HashMap是Java 1.2引进的Map接口的一个实现 <br />二.同步性:Hashtable是线程安全的，也就是说是同步的，而HashMap是线程序不安全的，不是同步的 <br />三.值：只有HashMap可以让你将空值作为一个表的条目的key或value <br />57、char型变量中能不能存贮一个中文汉字?为什么? <br />答：是能够定义成为一个中文的，因为java中以unicode编码，一个char占16个字节，所以放一个中文是没问题的 <br />58、多线程有几种实现方法,都是什么?同步有几种实现方法,都是什么? <br />答：多线程有两种实现方法，分别是继承Thread类与实现Runnable接口 <br />同步的实现方面有两种，分别是synchronized,wait与notify<br />59、垃圾回收机制,如何优化程序? <br />希望大家补上，谢谢 <br />60、float型float f=3.4是否正确? <br />答:不正确。精度不准确,应该用强制类型转换，如下所示：float f=(float)3.4 </p>
		<p>61、介绍JAVA中的Collection FrameWork(包括如何写自己的数据结构)? <br />答：Collection FrameWork如下： <br />Collection <br />├List <br />│├LinkedList <br />│├ArrayList <br />│└Vector <br />│　└Stack <br />└Set <br />Map <br />├Hashtable <br />├HashMap <br />└WeakHashMap <br />Collection是最基本的集合接口，一个Collection代表一组Object，即Collection的元素（Elements） <br />Map提供key到value的映射 <br />62、Java中异常处理机制，事件机制？ <br />11、JAVA中的多形与继承？ <br />希望大家补上，谢谢 <br />63、抽象类与接口？ <br />答：抽象类与接口都用于抽象，但是抽象类(JAVA中)可以有自己的部分实现，而接口则完全是一个标识(同时有多重继承的功能)。</p>
		<p>编程题：<br />1．现在输入n个数字，以逗号，分开；<br />然后可选择升或者降序排序；<br />按提交键就在另一页面显示<br />按什么 排序，结果为， ，<br />提供reset<br />答案（1） public static String[] splitStringByComma(String source){<br />  if(source==null||source.trim().equals(""))<br />  return null;<br />  StringTokenizer commaToker = new StringTokenizer(source,",");<br />  String[] result = new String[commaToker.countTokens()];<br />  int i=0;<br />  while(commaToker.hasMoreTokens()){<br />  result[ i ] = commaToker.nextToken();<br />  i++;<br />  }<br />  return result;<br />}<br />循环遍历String数组<br />Integer.parseInt(String s)变成int类型<br />组成int数组<br />Arrays.sort(int[] a),<br />a数组升序<br />降序可以从尾部开始输出</p>
		<p>2．金额转换，阿拉伯数字的金额转换成中国传统的形式如：<br />（￥1011）－&gt;（一千零一拾一元整）输出。 <br />3、继承时候类的执行顺序问题,一般都是选择题,问你将会打印出什么? <br />答:父类： <br />package test; <br />public class FatherClass <br />{ <br />public FatherClass() <br />{ <br />System.out.println("FatherClass Create"); <br />} <br />} <br />子类: <br />package test; <br />import test.FatherClass; <br />public class ChildClass extends FatherClass <br />{ <br />public ChildClass() <br />{ <br />System.out.println("ChildClass Create"); <br />} <br />public static void main(String[] args) <br />{ <br />FatherClass fc = new FatherClass(); <br />ChildClass cc = new ChildClass(); <br />} <br />} <br />输出结果： <br />C:&gt;java test.ChildClass <br />FatherClass Create <br />FatherClass Create <br />ChildClass Create </p>
		<p>4、内部类的实现方式? <br />答：示例代码如下： <br />package test; <br />public class OuterClass <br />{ <br />private class InterClass <br />{ <br />public InterClass() <br />{ <br />System.out.println("InterClass Create"); <br />} <br />} <br />public OuterClass() <br />{ <br />InterClass ic = new InterClass(); <br />System.out.println("OuterClass Create"); <br />} <br />public static void main(String[] args) <br />{ <br />OuterClass oc = new OuterClass(); <br />} <br />} <br />输出结果: <br />C:&gt;java test/OuterClass <br />InterClass Create <br />OuterClass Create <br />再一个例题： <br />public class OuterClass { <br />private double d1 = 1.0; <br />//insert code here <br />} <br />You need to insert an inner class declaration at line 3. Which two inner class declarations are </p>
		<p>valid?(Choose two.) <br />A. class InnerOne{ <br />public static double methoda() {return d1;} <br />} <br />B. public class InnerOne{ <br />static double methoda() {return d1;} <br />} <br />C. private class InnerOne{ <br />double methoda() {return d1;} <br />} <br />D. static class InnerOne{ <br />protected double methoda() {return d1;} <br />} <br />E. abstract class InnerOne{ <br />public abstract double methoda(); <br />} <br />说明如下： <br />一.静态内部类可以有静态成员，而非静态内部类则不能有静态成员。 故 A、B 错 <br />二.静态内部类的非静态成员可以访问外部类的静态变量，而不可访问外部类的非静态变量；return d1 出错。 </p>
		<p>故 D 错 <br />三.非静态内部类的非静态成员可以访问外部类的非静态变量。 故 C 正确 <br />四.答案为C、E </p>
		<p>5、Java 的通信编程，编程题(或问答)，用JAVA SOCKET编程，读服务器几个字符，再写入本地显示？ <br />答:Server端程序: <br />package test; <br />import java.net.*; <br />import java.io.*; <br />public class Server <br />{ <br />private ServerSocket ss; <br />private Socket socket; <br />private BufferedReader in; <br />private PrintWriter out; <br />public Server() <br />{ <br />try <br />{ <br />ss=new ServerSocket(10000); <br />while(true) <br />{ <br />socket = ss.accept(); <br />String RemoteIP = socket.getInetAddress().getHostAddress(); <br />String RemotePort = ":"+socket.getLocalPort(); <br />System.out.println("A client come in!IP:"+RemoteIP+RemotePort); <br />in = new BufferedReader(new </p>
		<p>InputStreamReader(socket.getInputStream())); <br />String line = in.readLine(); <br />System.out.println("Cleint send is :" + line); <br />out = new PrintWriter(socket.getOutputStream(),true); <br />out.println("Your Message Received!"); <br />out.close(); <br />in.close(); <br />socket.close(); <br />} <br />}catch (IOException e) <br />{ <br />out.println("wrong"); <br />} <br />} <br />public static void main(String[] args) <br />{ <br />new Server(); <br />} <br />}; <br />Client端程序: <br />package test; <br />import java.io.*; <br />import java.net.*; </p>
		<p>public class Client <br />{ <br />Socket socket; <br />BufferedReader in; <br />PrintWriter out; <br />public Client() <br />{ <br />try <br />{ <br />System.out.println("Try to Connect to 127.0.0.1:10000"); <br />socket = new Socket("127.0.0.1",10000); <br />System.out.println("The Server Connected!"); <br />System.out.println("Please enter some Character:"); <br />BufferedReader line = new BufferedReader(new </p>
		<p>InputStreamReader(System.in)); <br />out = new PrintWriter(socket.getOutputStream(),true); <br />out.println(line.readLine()); <br />in = new BufferedReader(new InputStreamReader(socket.getInputStream())); <br />System.out.println(in.readLine()); <br />out.close(); <br />in.close(); <br />socket.close(); <br />}catch(IOException e) <br />{ <br />out.println("Wrong"); <br />} <br />} <br />public static void main(String[] args) <br />{ <br />new Client(); <br />} <br />};</p>
		<p>6、用JAVA实现一种排序，JAVA类实现序列化的方法(二种)？ 如在COLLECTION框架中，实现比较要实现什么样的接口？ <br />答:用插入法进行排序代码如下 <br />package test; <br />import java.util.*; <br />class InsertSort <br />{ <br />ArrayList al; <br />public InsertSort(int num,int mod) <br />{ <br />al = new ArrayList(num); <br />Random rand = new Random(); <br />System.out.println("The ArrayList Sort Before:"); <br />for (int i=0;i&lt;num ;i++ ) <br />{ <br />al.add(new Integer(Math.abs(rand.nextInt()) % mod + 1)); <br />System.out.println("al["+i+"]="+al.get(i)); <br />} <br />} <br />public void SortIt() <br />{ <br />Integer tempInt; <br />int MaxSize=1; <br />for(int i=1;i&lt;al.size();i++) <br />{ <br />tempInt = (Integer)al.remove(i); <br />if(tempInt.intValue()&gt;=((Integer)al.get(MaxSize-1)).intValue()) <br />{ <br />al.add(MaxSize,tempInt); <br />MaxSize++; <br />System.out.println(al.toString()); <br />} else { <br />for (int j=0;j&lt;MaxSize ;j++ ) <br />{ <br />if </p>
		<p>(((Integer)al.get(j)).intValue()&gt;=tempInt.intValue()) <br />{ <br />al.add(j,tempInt); <br />MaxSize++; <br />System.out.println(al.toString()); <br />break; <br />} <br />} <br />} <br />} <br />System.out.println("The ArrayList Sort After:"); <br />for(int i=0;i&lt;al.size();i++) <br />{ <br />System.out.println("al["+i+"]="+al.get(i)); <br />} <br />} <br />public static void main(String[] args) <br />{ <br />InsertSort is = new InsertSort(10,100); <br />is.SortIt(); <br />} <br />} <br />JAVA类实现序例化的方法是实现java.io.Serializable接口 <br />Collection框架中实现比较要实现Comparable 接口和 Comparator 接口 <br />7、编程：编写一个截取字符串的函数，输入为一个字符串和字节数，输出为按字节截取的字符串。 但是要保证汉字不被截半个，如“我ABC”4，应该截为“我AB”，输入“我ABC汉DEF”，6，应该输出为“我ABC”而不是“我ABC+汉的半个”。 <br />答：代码如下： <br />package test; </p>
		<p>class SplitString <br />{ <br />String SplitStr; <br />int SplitByte; <br />public SplitString(String str,int bytes) <br />{ <br />SplitStr=str; <br />SplitByte=bytes; <br />System.out.println("The String is:′"+SplitStr+"′;SplitBytes="+SplitByte); <br />} <br />public void SplitIt() <br />{ <br />int loopCount; <br />loopCount=(SplitStr.length()%SplitByte==0)?(SplitStr.length()/SplitByte):(SplitStr.length()/Split <br />Byte+1); <br />System.out.println("Will Split into "+loopCount); <br />for (int i=1;i&lt;=loopCount ;i++ ) <br />{ <br />if (i==loopCount){ <br />System.out.println(SplitStr.substring((i-1)*SplitByte,SplitStr.length())); <br />} else { <br />System.out.println(SplitStr.substring((i-1)*SplitByte,(i*SplitByte))); <br />} <br />} <br />} <br />public static void main(String[] args) <br />{ <br />SplitString ss = new SplitString("test中dd文dsaf中男大3443n中国43中国人 </p>
		<p>0ewldfls=103",4); <br />ss.SplitIt(); <br />} <br />} <br />8、JAVA多线程编程。 用JAVA写一个多线程程序，如写四个线程，二个加1，二个对一个变量减一，输出。 <br />希望大家补上，谢谢 <br />9、STRING与STRINGBUFFER的区别。 <br />答：STRING的长度是不可变的，STRINGBUFFER的长度是可变的。如果你对字符串中的内容经常进行操作，特别是内容要修改时，那么使用StringBuffer，如果最后需要String，那么使用StringBuffer的toString()方法</p>
<img src ="http://www.blogjava.net/bily/aggbug/81601.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 20:40 <a href="http://www.blogjava.net/bily/articles/81601.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java认证模拟题及详细分析</title><link>http://www.blogjava.net/bily/articles/81597.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 12:27:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81597.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81597.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81597.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81597.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81597.html</trackback:ping><description><![CDATA[<p>1.Which statement about the garbage collection mechanism are true? <br />
A. Garbage collection require additional programe code in cases where multiple threads are running. <br />
B. The programmer can indicate that a reference through a local variable is no longer of interest. <br />
C. The programmer has a mechanism that explicity and immediately frees the memory used by Java objects. <br />
D. The garbage collection mechanism can free the memory used by Java Object at explection time. <br />
E. The garbage collection system never reclaims memory from objects while are still accessible to running user threads. </p>
<p>2. Give the following method: <br />
1) public void method( ){ <br />
2) String a,b; <br />
3) a=new String(&#8220;hello world&#8221;); <br />
4) b=new String(&#8220;game over&#8221;); <br />
5) System.out.println(a+b+&#8221;ok&#8221;); <br />
6) a=null; <br />
7) a=b; <br />
8) System.out.println(a); <br />
9) } <br />
In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection. <br />
A. before line 3 <br />
B.before line 5 <br />
C. before line 6 <br />
D.before line 7 <br />
E. Before line 9 </p>
<p>3. In the class java.awt.AWTEvent,which is the parent class upon which jdk1.1 awt events are based there is a method called getID which phrase accurately describes the return value of this method? <br />
A. It is a reference to the object directly affected by the cause of the event. <br />
B. It is an indication of the nature of the cause of the event. <br />
C. It is an indication of the position of the mouse when it caused the event. <br />
D. In the case of a mouse click, it is an indication of the text under the mouse at the time of the event. <br />
E. It tells the state of certain keys on the keybord at the time of the event. <br />
F. It is an indication of the time at which the event occurred. </p>
<p>4. Which statement about listener is true? <br />
A. Most component allow multiple listeners to be added. <br />
B. If multiple listener be add to a single component, the event only affected one listener.<br />
C. Component don?t allow multiple listeners to be add.<br />
&nbsp; D. The listener mechanism allows you to call an addXxxxListener method as many times as is needed, specifying as many different listeners as your design require. </p>
<p>5.Give the following code: <br />
public class Example{ <br />
public static void main(String args[] ){ <br />
int l=0; <br />
do{ <br />
System.out.println(&#8220;Doing it for l is:&#8221;+l); <br />
}while(--l&gt;0) <br />
System.out.println(&#8220;Finish&#8221;); <br />
} <br />
} <br />
Which well be output: <br />
A. Doing it for l is 3 <br />
B. Doing it for l is 1 <br />
C. Doing it for l is 2 <br />
D. Doing it for l is 0 <br />
E. Doing it for l is ?C1 <br />
F. Finish </p>
<p>见1-5题及详细分析： <br />
　　 1。B、E JAVA的垃圾回收机制是通过一个后台系统级线程对内存分配情况进行跟踪实现的，对程序员来说是透明的，程序员没有任何方式使无用内存显示的、立即的被释放。而且它是在程序运行期间发生的。 <br />
答案B告诉我们程序员可以使一个本地变量失去任何意义，例如给本地变量赋值为&#8220;null&#8221;；答案E告诉我们在程序运行期间不可能完全释放内存。 <br />
2。D第6行将null赋值给a以后，a以前保存的引用所指向的内存空间就失去了作用，它可能被释放。所以对象a可能最早被垃圾回收是在第7行以前，故选择D选项。 <br />
3。B请查阅JAVA类库。getID方法的返回值是&#8220;event type&#8221;。在认证考试中，总会有类似的书本以外的知识，这只能靠多实践来增长知识了。 <br />
4。A、D控件可以同时使用多个&#8220;addXxxxListener&#8221;方法加入多个监听器。并且当多个监听器加入到同一控件中时，事件可以响应多个监听器，响应是没有固定顺序的。 <br />
5。D、F本题主要考察考生对流程控制的掌握情况。这是当型循环，条件为真执行，条件为假则退出。循环体至少执行一次，故会输出D。循环体以外的语句总会被执行，故输出F。</p>
<p>&nbsp;&nbsp;&nbsp; 6. Give the code fragment: <br />
1) switch(x){ <br />
2) case 1:System.out.println(&#8220;Test 1&#8221;);break; <br />
3) case 2: <br />
4) case 3:System.out.println(&#8220;Test 2&#8221;);break; <br />
5) default:System.out.println(&#8220;end&#8221;); <br />
6) } <br />
which value of x would cause &#8220;Test 2&#8221; to the output: <br />
A. 1 <br />
B. 2 <br />
C. 3 <br />
D. default </p>
<p>7. Give incompleted method: <br />
1) <br />
2) { if(unsafe()){//do something&#8230;} <br />
3) else if(safe()){//do the other&#8230;} <br />
4) } <br />
The method unsafe() well throe an IOException, which completes the method of declaration when added at line one? <br />
A. public IOException methodName() <br />
B. public void methodName() <br />
C. public void methodName() throw IOException <br />
D. public void methodName() throws IOException <br />
E. public void methodName() throws Exception </p>
<p>8. Give the code fragment: <br />
if(x&gt;4){ <br />
System.out.println(&#8220;Test 1&#8221;);} <br />
else if (x&gt;9){ <br />
System.out.println(&#8220;Test 2&#8221;);} <br />
else { <br />
System.out.println(&#8220;Test 3&#8221;);} <br />
Which range of value x would produce of output &#8220;Test 2&#8221;? <br />
A. x&lt;4 <br />
B. x&gt;4 <br />
C. x&gt;9 <br />
D. None </p>
<p>9. Give the following method: <br />
public void example(){ <br />
try{ <br />
unsafe(); <br />
System.out.println(&#8220;Test1&#8221;); <br />
}catch(SafeException e){System.out.println(&#8220;Test 2&#8221;); <br />
}finally{System.out.println(&#8220;Test 3&#8221;);} <br />
System.out.println(&#8220;Test 4&#8221;); <br />
Which will display if method unsafe () run normally? <br />
A. Test 1 <br />
B. Test 2 <br />
C. Test 3 <br />
D. Test 4 </p>
<p>10. Which method you define as the starting point of new thread in a class from which new the thread can be excution? <br />
A. public void start() <br />
B. public void run() <br />
C. public void int() <br />
D. public static void main(String args[]) <br />
E. public void runnable() </p>
<p>6-10答案:<br />
6。B.C在开关语句中，标号总是不被当做语句的一部分，标号的作用就是做为条件判断而已，一旦匹配成功，就执行其后的语句，一直遭遇break语句为止。（包括default语句在内） <br />
7。D、F IOException异常类是Exception的子类。根据多态性的定义，IOException对象也可以被认为是Exception类型。还要注意在方法声明中抛出异常应用关键字&#8220;throws&#8221;。 <br />
8。D只有两种情况：大于4时输出&#8220;Test1&#8221;，小于等于4时输出&#8220;Test3&#8221;。 <br />
9。A、C、D在正常情况下，打印Test1、Test3、Test4；在产生可捕获异常时打印Test2、Test3、Test4；在产生不可捕获异常时，打印Test3，然后终止程序。注意finally后面的语句总是被执行。 <br />
10。B线程的执行是从方法&#8220;run( )&#8221;开始的，该方法是由系统调用的。程序员手工调用方法start()，使线程变为可运行状态。</p>
<p>&nbsp;&nbsp;&nbsp; 11.Given the following class definition: <br />
class A{ <br />
protected int i; <br />
A(int i){ <br />
this.i=i; <br />
} <br />
} <br />
which of the following would be a valid inner class for this class? <br />
Select all valid answers: <br />
A. class B{ <br />
} <br />
B. class B extends A{ <br />
} <br />
C. class B extends A{ <br />
B(){System.out.println(&#8220;i=&#8221;+i);} <br />
} <br />
D. class B{ <br />
class A{} <br />
} <br />
E. class A{} </p>
<p>12. Which modifier should be applied to a method for the lock of object this to be obtained prior to excution any of the method body? <br />
A. synchronized <br />
B. abstract <br />
C. final <br />
D. static <br />
E. public </p>
<p>13. The following code is entire contents of a file called Example.java,causes precisely one error during compilation: <br />
1) class SubClass extends BaseClass{ <br />
2) } <br />
3) class BaseClass(){ <br />
4) String str; <br />
5) public BaseClass(){ <br />
6) System.out.println(&#8220;ok&#8221;);} <br />
7) public BaseClass(String s){ <br />
8) str=s;}} <br />
9) public class Example{ <br />
10) public void method(){ <br />
11) SubClass s=new SubClass(&#8220;hello&#8221;); <br />
12) BaseClass b=new BaseClass(&#8220;world&#8221;); <br />
13) } <br />
14) } <br />
Which line would be cause the error? <br />
A. 9 B. 10 C. 11 D.12 </p>
<p>14. Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object? <br />
A. String [] a <br />
B. String a[] <br />
C. char a[][] <br />
D. String a[50] <br />
F. Object a[50] </p>
<p>15. Give the following java source fragement: <br />
//point x <br />
public class Interesting{ <br />
//do something <br />
} <br />
Which statement is correctly Java syntax at point x? <br />
A. import java.awt.*; <br />
B.package mypackage <br />
C. static int PI=3.14 <br />
D. public class MyClass{//do other thing&#8230;} E. class MyClass{//do something&#8230;}</p>
<p>11-15答案：<br />
11。A此题考查内部类及关键字&#8220;super&#8221;的用法。内部类不能与外部类同名。另外，当Ｂ继承Ａ时，Ａ中的构造函数是带参数的，Ｂ中缺省构造函数的函数体为空；而ＪＡＶＡ编译器会为空构造函数体自动添加语句&#8220;super();&#8221;调用父类构造函数，更进一步是调用父类的参数为空的构造函数。而父类中没有参数为空的构造函数。 <br />
12。A此关键字可以在两个线程同时试图访问某一数据时避免数据毁损。 <br />
13。C当一个类中未显式定义构造函数时，缺省的构造函数是以类名为函数名，参数为空，函数体为空。虽然父类中的某一构造函数有字符串参数s，但是子类继承父类时并不继承构造函数，所以它只能使用缺省构造函数。故在第11行出错。 <br />
14。A、B注意，题中问的是如何正确声明一个一维数组，并非实例化或者初始化数组 <br />
15。A、E X处可以是一个输入，包的定义，类的定义。由于常量或变量的声明只能在类中或方法中，故不能选择C；由于在一个文件中只能有一个public类，故不能选择D。</p>
<p>&nbsp;&nbsp;&nbsp; 16. Give this class outline: <br />
class Example{ <br />
private int x; <br />
//rest of class body&#8230; <br />
} <br />
Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java? <br />
A. Change private int x to public int x <br />
B. change private int x to static int x <br />
C. Change private int x to protected int x <br />
D. change private int x to final int x </p>
<p>17. the piece of preliminary analsis work describes a class that will be used frequently in many unrelated parts of a project <br />
&#8220;The polygon object is a drawable, A polygon has vertex information stored in a vector, a color, length and width.&#8221; <br />
Which Data type would be used? <br />
A. Vector <br />
B. int <br />
C. String <br />
D. Color <br />
E. Date </p>
<p>18. A class design requires that a member variable should be accessible only by same package, which modifer word should be used? <br />
A. protected <br />
B. public <br />
C. no modifer <br />
D. private </p>
<p>19.Which declares for native method in a java class corrected? <br />
A. public native void method(){} <br />
B. public native void method(); <br />
C. public native method(); <br />
D. public void method(){native;} <br />
E. public void native method(); </p>
<p>20. Which modifer should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object? </p>
<p>16-20答案：<br />
16。B <br />
静态方法除了自己的参数外只能直接访问静态成员。访问非静态成员，必须先实例化本类的一个实例，再用实例名点取。 <br />
17。A、B、D <br />
polygon的顶点信息存放在Vector类型的对象内部，color定义为Color，length和width定义为int。 <br />
注意，这是考试中常见的题型。 <br />
18。C <br />
此题考点是高级访问控制。请考生查阅高级访问控制说明表格。 <br />
19。B <br />
native关键字指明是对本地方法的调用，在JAVA中是只能访问但不能写的方法，它的位置在访问权限修饰语的后面及返回值的前面。 <br />
20。final <br />
定义常量的方法是在变量定义前加final关键字。 </p>
<p>21. Which is the main() method return of a application? <br />
A. String <br />
B. byte <br />
C. char <br />
D. void </p>
<p>22. Which is corrected argument of main() method of application? <br />
A. String args <br />
B. String ar[] <br />
C. Char args[][] <br />
D. StringBuffer arg[] </p>
<p>23. &#8220;The Employee object is a person, An Employee has appointment store in a vector, a hire date and a number of dependent&#8221; <br />
short answer: use shortest statement declare a class of Employee. </p>
<p>24. Give the following class defination inseparate source files: <br />
public class Example{ <br />
public Example(){//do something} <br />
protected Example(int i){//do something} <br />
protected void method(){//do something} <br />
} <br />
public class Hello extends Example{//member method and member variable} <br />
Which methods are corrected added to the class Hello? <br />
A. public void Example(){} <br />
B. public void method(){} <br />
C. protected void method(){} <br />
D. private void method(){} </p>
<p>25. Float s=new Float(0.9F); <br />
Float t=new Float(0.9F); <br />
Double u=new Double(0.9); <br />
Which expression?s result is true? <br />
A. s==t <br />
B. s.equals(t) <br />
C. s==u <br />
D. t.equals(u) </p>
<p>21-15答案：<br />
21。D <br />
main()方法没有返回值，所以必须用void修饰。main()方法的返回值不能任意修改。 <br />
22。B <br />
main()方法的参数是字符串数组，参数名可以任意定义。 <br />
23。public class Employee extends Person <br />
这也是真实考试中常见的一种题型。要注意题目叙述中&#8220;is a&#8221;表示 &#8220;extends&#8221;的含义。 <br />
24。A、B、C <br />
考察的知识点是方法覆盖，其中要注意的是方法覆盖时，子类方法的访问权限不能小于父类方法的访问权限。另外，选项A并不是父类构造函数，它是子类中的新方法。 <br />
25。A、B <br />
考察&#8220;==&#8221;及方法&#8220;equals()&#8221;的用法。注意以下几点区别： <br />
1） 引用类型比较引用；基本类型比较值。 <br />
2） equals()方法只能比较引用类型，&#8220;==&#8221;可比较引用及基本类型。 <br />
3） 当用equals()方法进行比较时，对类File、String、Date及封装类（Wrapper Class）来说，是比较类型及内容。 <br />
4） 用&#8220;==&#8221;进行比较时，符号两边的数据类型必须一致（可相互转换的基本类型除外），否则编译出错。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 26. Give following class: <br />
　　 class AClass{ <br />
　　 private long val; <br />
　　 public AClass(long v){val=v;} <br />
　　 public static void main(String args[]){ <br />
　　 AClass x=new AClass(10L); <br />
　　 AClass y=new AClass(10L); <br />
　　 AClass z=y; <br />
　　 long a=10L; <br />
　　 int b=10; <br />
　　 } <br />
　　 } <br />
　　 Which expression result is true? <br />
　　 A. a==b; <br />
　　 B. a==x; <br />
　　 C. y==z; <br />
　　 D. x==y; <br />
　　 E. a==10.0; </p>
<p>　　 27. A socket object has been created and connected to a standard internet service on a remote network server. Which construction give the most suitable means for reading ASCII data online at a time from the socket? <br />
　　 A. InputStream in=s.getInputStream(); <br />
　　 B. DataInputStream in=new DataInputstream(s.getInputStream()); <br />
　 C. ByteArrayInputStream in = new ByteArrayInputStream (s.getInputStream()); <br />
　　 D. BufferedReader in=new BufferedReader (new InputStreamReader (s.getInputStream())); <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; E. BufferedReader in=new BufferedReader (new InputStreamReader (s.getInputStream()),&#8221;8859-1&#8221;); </p>
<p>　　 28. String s=&#8221;Example String&#8221;; <br />
　　 Which operation is legal? <br />
　　 A. s&gt;&gt;&gt;=3; <br />
　　 B. int i=s.length(); <br />
　　 C. s[3]=&#8221;x&#8221;; <br />
　　 D. String short_s=s.trim(); <br />
　　 E. String t=&#8221;root&#8221;+s; </p>
<p>　　 29. What happens when you try to compile and run the following program? <br />
　　 class Mystery{ <br />
　　 String s; <br />
　　 public static void main(String[] args){ <br />
　　 Mystery m=new Mystery(); <br />
　　 m.go(); <br />
　　 } <br />
　　 void Mystery(){ <br />
　　 s=&#8221;constructor&#8221;; <br />
　　 } <br />
　　 void go(){ <br />
　　 System.out.println(s); <br />
　　 } <br />
　　 } <br />
　　 A. this code will not compile <br />
　　 B. this code compliles but throws an exception at runtime <br />
　　 C. this code runs but nothing appears in the standard output <br />
　　 D. this code runs and &#8220;constructor&#8221; in the standard output <br />
　　 E. this code runs and writes &#8221;null&#8221; in the standard output </p>
<p>　　 30. What use to position a Button in a Frame ,only width of Button is affected by the Frame size, which Layout Button well be set ? <br />
　　 A. FlowLayout; <br />
　　 B. GridLayout; <br />
　　 C. North of BorderLayout <br />
　　 D. South of BorderLayout <br />
　　 E. East or West of BorderLayout<br />
&nbsp;<br />
　　 31. What use to position a Button in a Frame, size of Button is not affected by the Frame size, which Layout Button will be set? <br />
　　 A. FlowLayout; <br />
　　 B. GridLayout; <br />
　　 C. North of BorderLayout <br />
　　 D. South of BorderLayout <br />
　　 E. East or West of BorderLayout </p>
<p>　　 32. An AWT GUI under exposure condition, which one or more method well be invoke when it redraw? <br />
　　 A. paint(); <br />
　　 B. update(); <br />
　　 C. repaint(); <br />
　　 D. drawing(); </p>
<p>　　 33. Select valid identifier of Java: <br />
　　 A. userName <br />
　　 B. %passwd <br />
　　 C. 3d_game <br />
　　 D. $charge E. this </p>
<p>　　 34. Which are Java keyword? <br />
　　 A. goto <br />
　　 B. null <br />
　　 C. FALSE <br />
　　 D. native <br />
　　 E. const </p>
<p>　　 35. Run a corrected class: java ?Ccs AClass a b c <br />
　　 Which statement is true? <br />
　　 A. args[0]=&#8221;-cs&#8221;; <br />
　　 B. args[1]=&#8221;a b c&#8221;; <br />
　　 C. args[0]=&#8221;java&#8221;; <br />
　　 D. args[0]=&#8221;a&#8221;; E. args[1]=?b?<br />
&nbsp;<br />
　　 36. Give the following java class: <br />
　　 public class Example{ <br />
　　 static int x[]=new int[15]; <br />
　　 public static void main(String args[]){ <br />
　　 System.out.println(x[5]); <br />
　　 } <br />
　　 } <br />
　　 Which statement is corrected? <br />
　　 A. When compile, some error will occur. <br />
　　 B. When run, some error will occur. <br />
　　 C. Output is zero. <br />
　　 D. Output is null. </p>
<p>　　 37. Give the following java class: <br />
　　 public class Example{ <br />
　　 public static void main(String args[]){ <br />
　　 static int x[] = new int[15]; <br />
　　 System.out.println(x[5]); <br />
　　 } <br />
　　 } <br />
　　 Which statement is corrected? <br />
　　 A. When compile, some error will occur. <br />
　　 B. When run, some error will occur. <br />
　　 C. Output is zero. <br />
　　 D. Output is null. </p>
<p>　　 38. Short answer: <br />
　　 The decimal value of i is 12, the octal i value is: </p>
<p>　　 39. Short answer: <br />
　　 The decimal value of i is 7, the hexadecimal i value is: </p>
<p>　　 40. Which is the range of char? <br />
　　 A. 27~27-1 <br />
　　 B. 0~216-1 <br />
　　 C. 0~216 <br />
　　 D. 0~28 <br />
　&nbsp;&nbsp; <br />
&nbsp;&nbsp;&nbsp;&nbsp; 41. Which is the range of int type? <br />
　　 A. -216~216-1 <br />
　　 B.- 231~231-1 <br />
　　 C. -232~232-1 <br />
　　 D. -264~264-1 </p>
<p>　　 42. Give the following class: <br />
　　 public class Example{ <br />
　　 String str=new String(&#8220;good&#8221;); <br />
　　 char ch[]={ <br />
　　 public static void main(String args[]){ <br />
　　 Example ex=new Example(); <br />
　　 ex.change(ex.str,ex.ch); <br />
　　 System.out.println(ex.str+&#8221;and&#8221;+ex.ch); <br />
　　 } <br />
　　 public void change(String str,char ch[]){ <br />
　　 str=&#8221;test ok&#8221;;ch[0]=?g? <br />
　　 } <br />
　　 } <br />
　　 Which is the output: <br />
　　 A. good and abc <br />
　　 B. good and gbc <br />
　　 C. test ok and abc <br />
　　 D. test ok and gbc </p>
<p>　　 43. Which code fragments would correctly identify the number of arguments passed via command line to a Java application, exclude the name of the class that is being invoke. <br />
　　 A. int count = args.length; <br />
　　 B. int count = args.length-1; <br />
　　 C. int count=0; while(args[count]!=null) count++; <br />
　　 D. int count=0;while (!(args[count].equals(&#8220;&#8221;))) count++; </p>
<p>　　 44. FilterOutputStream is the parent class for BufferedOutputStream, DataOutputStream and PrintStream. Which classes are valid argument for the constructor of a FilterOutputStream? <br />
　　 A. InputStream <br />
　　 B. OutputStream <br />
　　 C. File <br />
　　 D. RandomAccessFile <br />
　　 E. StreamTokenizer </p>
<p>　　 45. Given a TextArea using a proportional pitch font and constructed like this: <br />
TextArea t=new TextArea(&#8220;12345&#8221;,5,5); <br />
Which statement is true? <br />
　　 A. The displayed width shows exactly five characters one each line unless otherwise constrained <br />
　　 B. The displayed height is five lines unless otherwise constrained <br />
　　 C. The maximum number of characters in a line will be five <br />
　　 D. The user will be able to edit the character string <br />
　　 E. The displayed string can use multiple fonts</p>
<p>　　 46. Given a List using a proportional pitch font and constructed like this: <br />
List l=new List(5,true); <br />
Which statement is true? <br />
　　 A. The displayed item exactly five lines unless otherwise constrained <br />
　　 B. The displayed item is five lines init, but can displayed more than five Item by scroll <br />
　　 C. The maximum number of item in a list will be five. <br />
　　 D. The list is multiple mode </p>
<p>　　 47. Given this skeleton of a class currently under construction: <br />
　　 public class Example{ <br />
　　 int x,y,z; </p>
<p>　　 public Example (int a, int b) { <br />
　　 //lots of complex computation <br />
　　 x=a; y=b; <br />
　　 } <br />
　　 public Example(int a, int b, int c){ <br />
　　 // do everything the same as single argument <br />
　　 // version of constructor <br />
　　 // including assignment x=a, y=b, z=c <br />
　　 z=c; <br />
　　 } <br />
　　 } <br />
　　 What is the most concise way to code the &#8220;do everything&#8230;&#8221; part of the constructor taking two arguments? <br />
　　 Short answer: </p>
<p>　　 48. Which correctly create a two dimensional array of integers? <br />
　　 A. int a[][] = new int[][]; <br />
　　 B. int a[10][10] = new int[][]; <br />
　　 C. int a[][] = new int[10][10]; <br />
　　 D. int [][]a = new int[10][10]; <br />
　　 E. int []a[] = new int[10][10]; </p>
<p>　　 49. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java? <br />
　　 A. public class Fred{ <br />
　　 public int x = 0; <br />
　　 public Fred (int x){ <br />
　　 this.x=x; <br />
　　 } <br />
　　 } <br />
　　 B. public class fred{ <br />
　　 public int x = 0; <br />
　　 public Fred (int x){ <br />
　　 this.x=x; <br />
　　 } <br />
　　 } <br />
　　 C. public class Fred extends MyBaseClass, MyOtherBaseClass{ <br />
　　 public int x = 0; <br />
　　 public Fred(int xval){ <br />
　　 x=xval; <br />
　　 } <br />
　　 } <br />
　　 D. protected class Fred{ <br />
　　 private int x = 0; <br />
　　 private Fred (int xval){ <br />
　　 x=xval; <br />
　　 } <br />
　　 } <br />
　　 E. import java.awt.*; <br />
　　 public class Fred extends Object{ <br />
　　 int x; <br />
　　 private Fred(int xval){ <br />
　　 x = xval; <br />
　　 } <br />
　　 }<br />
&nbsp;<br />
　　 50. A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same package. What should be done to achieve this? <br />
　　 A. The variable should be marked public <br />
　　 B. The variable should be marked private <br />
　　 C. The variable should be marked protected <br />
　　 D. The variable should have no special access modifier <br />
　　 E. The variable should be marked private and an accessor method provided </p>
<p>答案及详细分析： <br />
26。A、C、E <br />
考察的知识点是比较基本类型与对象类型的不同之处，基本类型进行的是值比较，而对象类型进行的是地址比较，也就是对指向它们内存地址的指针进行比较。 <br />
27。E <br />
在程序中实现字节与字符转换时，采用规范&#8220;ISO8859-1&#8221;是最适宜的方式。 <br />
28。B、D、E <br />
移位操作只对整型有效，故不能选A；String类型并非数组，故不能用C所示方法取其中的某一位；B中的length方法返回字符串长度；D中trim方法返回字符串去掉其前后的空格后的新字符串；字符串可以用&#8220;+&#8221;进行合并。 <br />
29。E <br />
回答本题时要细心阅读程序，注意&#8220;void Mistery(){}&#8221;并非构造函数，因为构造函数是没有返回值时，它只是与类名一致的方法名而已。注意到这一点，此题就没有什么难度了。 <br />
30。C、D <br />
考察对布局管理器知识的掌握情况。BorderLayout的特性是当容器的尺寸改变时，North、South、West、East位置控件的较窄边长度不变，较长边长度变化。但控件的相对位置不变。 <br />
31。A <br />
FlowLayout的特性是其中的控件大小不随着容器尺寸的变化而变化，但控件的相对位置会有所改变。 <br />
32。A(多选) <br />
请注意，此题虽然是多选题，但正确答案只有一个。不管在什么情况下，图形要进行重绘，最终总会调用paint()方法，而且也只有paint()方法总会被调用。 <br />
33。A、D <br />
Java中的标识符是以字符开头，字符包括字母、下划线&#8220;_&#8221;、美圆符&#8220;$&#8221;。不能以数字开头，也不能是Java关键字。 <br />
34。A、B、D、E <br />
注意：goto、const是Java关键字，但是不使用。 <br />
35。D <br />
cs是运行时可选择的java命令的参数，类名后才是由用户指定的传入程序中的实参，并且参数是字符串类型，故E也是不正确的。 <br />
36。C <br />
数组是引用类型，它的元素相当于类的成员变量，而成员变量是可以被隐式初始化的，所以数组的元素也可以被隐式初始化，int类型被隐式初始化为0，所以选择C。 <br />
37。A <br />
自动变量不能被static修饰，如果将static关键字去掉，答案选择C。<br />
&nbsp; 38。014 <br />
将十进制化成八进制后在数字前加&#8220;0&#8221;。 <br />
39。0x7 <br />
十六进制数用在数字前加&#8220;0x&#8221;表示。 <br />
40。B <br />
字符类型是用16位UniCode表示的。 <br />
41。B <br />
整型数的取值范围是- 2n~2n-1，n表示各种类型的表示位数。 <br />
42。B <br />
JAVA中的参数传递全是值传递，所不同的是，对于引用类型来说，变量内部存放的是对象内存空间的引用，所以引用类型在进行参数传递时，是将引用拷贝给形式参数。所以在方法中绝不可能改变主调方法中引用变量的引用，但是可能改变主调方法中引用变量的某一属性（就象对ch[0]的改变一样）。 <br />
43。A <br />
注意main()方法的参数数组是在程序运行时由系统创建的，大小已经固定了。选项C、D引用args[count]可能会导致数组指针越界异常。 <br />
44。B <br />
请查阅类结构，并注意他们的继承关系。这主要考查流链知识点。 <br />
45。B <br />
控件TextArea如题中的构造方法的后两个参数分别表示行、列。注意题中的关键词语&#8220;prorortional pitch&#8221;，所以不一定是5列字，但一定是5行。 <br />
46。B <br />
&#8220;5&#8221;表示可以选择的项目数显示为5行，但可以拖动滑块观察其它选项。&#8220;true&#8221;表示可以多选。 <br />
47。this(a,b); <br />
注意教材中提到使用this方法可以简化构造函数的编写。此时它必须放在构造函数的第一句。 <br />
48。C、D、E <br />
JAVA语言中声明数组时，方括号与变量的位置关系非常灵活。 <br />
49。A、E <br />
Java中大小写敏感，注意文件名是Fred.java，故B错误；Java中不支持多继承，故C错误；Java中与文件名相同的类名的访问权限一定是public，故D错误。 <br />
50。C <br />
请查阅关于访问权限的表格说明。</p>
<p><br />
&nbsp;&nbsp;&nbsp;&nbsp; 51. Which correctly create an array of five empty Strings? <br />
　　 A. String a[] = new String[5]; <br />
　　 for (int i=0;i&lt;5;a[i++]=&#8221;&#8221;); <br />
　　 B. String a []={&#8220;&#8221;,&#8221;&#8221;,&#8221;&#8221;,&#8221;&#8221;,&#8221;&#8221;}; <br />
　　 C. String a[5]; <br />
　　 D. String [5] a; <br />
　　 E. String [] a = new String[5]; <br />
　　 for (int i = 0 ;i&lt;5;a[i++] = null); </p>
<p>　　 52. Which cannot be added to a Container? <br />
　　 A. an Applet <br />
　　 B. a Component <br />
　　 C. a Container <br />
　　 D. a MenuComponent <br />
　　 E. a panel </p>
<p>　　 53. Which is the return value of Event listener?s method? <br />
　　 A. String B. AWTEvent C. void D. int </p>
<p>　　 54. If we implements MouseListener, which is corrected argument of its method? (short answer) </p>
<p>　　 55. Use the operator &#8220;&gt;&gt;&#8221; and &#8220;&gt;&gt;&gt;&#8221;. Which statement is true? <br />
　　 A. 1010 0000 0000 0000 0000 0000 0000 0000 &gt;&gt; 4 give <br />
　　 0000 1010 0000 0000 0000 0000 0000 0000 <br />
　　 B. 1010 0000 0000 0000 0000 0000 0000 0000 &gt;&gt; 4 give <br />
　　 1111 1010 0000 0000 0000 0000 0000 0000 <br />
　　 C. 1010 0000 0000 0000 0000 0000 0000 0000 &gt;&gt;&gt; 4 give <br />
　　 0000 1010 0000 0000 0000 0000 0000 0000 <br />
　　 D. 1010 0000 0000 0000 0000 0000 0000 0000 &gt;&gt;&gt; 4 give <br />
　　 1111 1010 0000 0000 0000 0000 0000 0000 </p>
<p>　　 56. Give following fragment. <br />
　　 Outer: for(int i=0; i&lt;3; i++) <br />
　　 inner:for(int j=0;j&lt;3;j++){ <br />
　　 If(j&gt;1)break outer; <br />
　　 System.out.println(j+&#8221;and&#8221;+i); <br />
　　 } <br />
　　 Which will be output? <br />
　　 A. 0 and 0 B. 0 and 1 C. 0 and 2 D. 0 and 3 <br />
　　 E. 1 and 0 F. 1 and 1 G. 1 and 2 H. 1 and 3 <br />
　　 I. 2 and 0 J. 2 and 1 K. 2 and 2 L. 2 and 3 </p>
<p>　　 57. Examine the following code which includes an inner class: <br />
　　 public final class Test4 implements A{ <br />
　　 class Inner{ <br />
　　 void test(){ <br />
　　 if (Test4.this.flag);{ <br />
　　 sample(); <br />
　　 } <br />
　　 } <br />
　　 private boolean flag=false; <br />
　　 } <br />
　　 public void sample(){ <br />
　　 System.out.println(&#8220;Sample&#8221;); <br />
　　 } <br />
　　 public Test4(){ <br />
　　 (new Inner()).test(); <br />
　　 } <br />
　　 public static void main(String args[]){ <br />
　　 new Test4(); <br />
　　 } <br />
　　 } <br />
　　 What is the result: <br />
　　 A.Print out &#8220;Sample&#8221; <br />
　　 B.Program produces no output but termiantes correctly. <br />
　　 C. Program does not terminate. <br />
　　 D.The program will not compile </p>
<p>　　 58. What is written to the standard output given the following statement: <br />
　　 System.out.println(4|7); <br />
　　 Select the right answer: <br />
　　 A.4 <br />
　　 B.5 <br />
　　 C.6 <br />
　　 D.7 <br />
　　 E.0 </p>
<p>　　 59. Look the inheritance relation: <br />
　　 person <br />
&nbsp;&nbsp;&nbsp;&nbsp; | <br />
&nbsp;&nbsp;&nbsp;&nbsp; ---------------- <br />
　　 | | <br />
man woman <br />
　　 In a source of java have the following line: <br />
　　 person p=new man(); <br />
　　 What statement are corrected? <br />
　　 A. The expression is illegal. <br />
　　 B. Compile corrected but running wrong. <br />
　　 C. The expression is legal. <br />
　　 D. Will construct a person?s object. <br />
　　 60. Look the inheritance relation: <br />
　　 person <br />
　　 | <br />
　　 ---------------- <br />
　　 | | <br />
　　 man woman <br />
　　 In a source of java have the following line: <br />
　　 woman w=new man(): </p>
<p>　　 What statement are corrected? <br />
　　 A. The expression is illegal. <br />
　　 B. Compile corrected but running wrong. <br />
　　 C. The expression is legal. <br />
　　 D. Will construct a woman object. </p>
<p>　　 61． Which can NOT be used in declaring or declaring and initializing an automatic (method local) variable? <br />
　　 A. final <br />
　　 B. static <br />
　　 C. expressions <br />
　　 D. Constants of non-primitive type <br />
　　 E. initialized arrays (such as &#8220; {&#8220;Hello&#8221;,&#8221;Good bye&#8221;}&#8221;). </p>
<p>　　 62． Given the following incomplete method: <br />
　　 1) public void method(){ <br />
　　 2) <br />
　　 3) if (someTestFails()){ <br />
　　 4) <br />
　　 5) } <br />
　　 6) <br />
　　 7) } <br />
　　 You want to make this method throw an IOException if,and only if,the method someTestFails() returns a value of true. <br />
　　 Which changes achieve this? <br />
　　 A. Add at line 2:IOException e; <br />
　　 B. Add at line 4:throw e; <br />
　　 C. Add at line 4:throw new IOException(); <br />
　　 D. Add at line 6:throw new IOException(); <br />
　　 E. Modify the method declaration to indicate that an object of type Exception might be thrown.<br />
&nbsp;<br />
　　 63． Given the following definition: <br />
　　 String s = null; <br />
　　 Which code fragments cause an object of type NullPointerException to be thrown? <br />
　　 A. if((s!=null)&amp;(s.length()&gt;0)) <br />
　　 B. if((s!=null)&amp;&amp;(s.length()&gt;0)) <br />
　　 C. if((s==null)|(s.length()==0)) <br />
　　 D. if((s==null)||(s.length()==0)) </p>
<p>　　 64． The following is a program <br />
　　 1) class Exsuper{ <br />
　　 2) String name; <br />
　　 3) String nick_name; <br />
　　 4) <br />
　　 5) public ExSuper(String s,String t){ <br />
　　 6) name = s; <br />
　　 7) nick_name = t; <br />
　　 8) } <br />
　　 9) <br />
　　 10) public string toString(){ <br />
　　 11) return name; <br />
　　 12) } <br />
　　 13) } <br />
　　 14) <br />
　　 15) public class Example extends ExSuper{ <br />
　　 16) <br />
　　 17) public Example(String s,String t){ <br />
　　 18) super(s,t); <br />
　　 19) } <br />
　　 20) <br />
　　 21) public String to String(){ <br />
　　 22) return name +&#8221;a.k.a&#8221;+nick_name; <br />
　　 23) } <br />
　　 24) <br />
　　 25) public static void main(String args[]){ <br />
　　 26) ExSuper a = new ExSuper(&#8220;First&#8221;,&#8221;1st&#8221;); <br />
　　 27) ExSuper b = new Example(&#8220;Second&#8221;,&#8221;2nd&#8221;); <br />
　　 28) <br />
　　 29) System.out.println(&#8220;a is&#8221;+a.toString()); <br />
　　 30) System.out.println(&#8220;b is&#8221;+b.toString()); <br />
　　 31) } <br />
　　 32) } <br />
　　 What happens when the user attempts to compile and run this program? <br />
　　 A. A Compiler error occurs at line 21 <br />
　　 B. An object of type ClassCastException is thrown at line 27 <br />
　　 C.The following output: <br />
　　 a is First <br />
　　 b is second <br />
　　 D. The following output: <br />
　　 a is First <br />
　　 b is Secong a.k.a 2nd <br />
　　 F. The following output: <br />
　　 a is First a.k.a 1st <br />
　　 b is Second a.k.a 2nd </p>
<p>　　 65． Which statements are true about Listeners? <br />
　　 A. At most one listener can be added to any simple Component. <br />
　　 B. The return value from a listener is used to control the invocation of other listener <br />
　　 C. If multiple listeners are added to a single component, they must all be made friends to each other <br />
　　 D. If multiple listeners are added to single component, the order of invocation of the listener is not specified. <br />
　　 E. In the AWT, listener methods generally take an argument, which is an instance of some subclass of java.awt.AWTEvent class. </p>
<p>答案及详细分析： <br />
51。A、B <br />
注意，每个对象变量在未初始化前都为&#8220;null&#8221;，并不为&#8220;空&#8221;。当为&#8220;空&#8221;时，它已经被分配具体内存空间了，与&#8220;null&#8221;有本质的区别。 <br />
52。D <br />
菜单控件只能添加到叫做菜单容器的特殊对象中，而且布局管理器对菜单控件不起任何作用。 <br />
53。C <br />
事件监听器方法就是句柄方法，所有句柄方法的访问权限都是public，返回值类型都是void。 <br />
54。MouseEvent <br />
此题是考试中常见的题型。一般来说，句柄方法的参数类型与监听器类型是匹配的，只有监听器MouseMotionListener的句柄方法的参数类型是MouseEvent，与相应监听器类型名称不匹配。 <br />
55。B、C <br />
&#8220;&gt;&gt;&#8221; 是带符号右移，高位是&#8220;1&#8221;则补&#8220;1&#8221;，否则补&#8220;0&#8221;；&#8220;&gt;&gt;&gt;&#8221;是无符号右移，又叫补零右移，不论高位是什么，都是补&#8220;0&#8221;。 <br />
56。A、E <br />
注意标号的使用。另外，break表示跳出本语句块的执行，continue继续本块的执行。 <br />
57。A <br />
回答此题时，要仔细阅读程序，注意到语句&#8220;if(Test4.this.flag);&#8221;有一分号，这是没有执行语句的条件语句，所以&#8220;sample()&#8221;方法总是被调用。 <br />
58。D <br />
&#8220;|&#8221;是按位或运算符，先将4和7转为二进制数。转换后就是计算&#8220;100|111&#8221;，所以得到结果是&#8220;111&#8221;，转为十进制整形数是7。此题提醒考生注意，要熟悉各种运算符号的含义。 <br />
59。C <br />
这是多态性的定义方式，p是父类引用指向子类对象。此时，编译器认为p是一个person，而不是man ，所以p只能实现父类的功能。但是当p调用被覆盖方法时，是指向子类中的该方法。 <br />
60．A <br />
多态性的定义允许父类引用指向子类对象，但是不允许两个平等的子类有这样的操作。所以该表达式是不合法的。 <br />
61．B <br />
自动变量前不能用&#8220;static&#8221;修饰。 <br />
以下定义都是允许的： <br />
final Date d = new Date(); <br />
String [] s = {&#8220;Hello&#8221;,&#8221;abc&#8221;}; <br />
int i = x+4; <br />
所以只有B选项是正确。 <br />
62．C、E <br />
所有自定义异常，在方法体中抛出了，就必须在方法声明中抛出。所以除了C选项外，E也必须入选。 <br />
63．A、C <br />
逻辑运算符&#8220;&amp;&amp;&#8221;、&#8220;||&#8221;，在运算中有&#8220;短路&#8221;行为：例如 A&amp;&amp;B,如果A的值为false，则直接将整个表达式的值置为false，对B的值不加考察。而运算符&#8220;&amp;&#8221;、&#8220;|&#8221;就没有这种行为。所以在选项A、C中，&#8220;s.length()&#8221;会导致抛出空指针异常。 <br />
64．D <br />
　　 源程序的第27行，是多态性的定义。对象b调用被覆盖方法时是调用子类中的该方法。 <br />
65．D、E <br />
　　 一个控件可以注册多个监听器，并且事件的响应没有特定的顺序。句柄方法的参数是类AWTEvent类的子类。</p>
<p>　　 66． Given the following class outline: <br />
　　 class Example{ <br />
　　 private int x; <br />
　　 // rest of class body <br />
　　 public static void main(String args[]){ <br />
　　 //implementation of main mehtod} <br />
　　 } <br />
　　 Which statement is true? <br />
　　 A. x=2 is a valid assignment in the main() method of class Example. <br />
　　 B. Changing private int x to int x would make x=2 a valid assignment in the main() method of class Example. <br />
　　 C. Changing private int x to public int x would make x=2 a valid assignment in the main() method of class Example. <br />
　　 D. Changing private int x to static int x would make x=2 a valid assignment in 　the main() method of class Example. <br />
　　 E. Changing class Example to public class Example would make x=2 a valid assignment in the main() method of class Example. </p>
<p>　　 67． Which statement is true about an inner class? <br />
　　 A. It must be anonymous <br />
　　 B. It can not implement an interface <br />
　　 C. It is only accessible in the enclosing class <br />
　　 D. It can access any final variables in any enclosing scope. </p>
<p>　　 68． Which statement is true about the grid bag layout manager? <br />
　　 A. The number of rows and columns is fixed when the container is created. <br />
　　 B. The number of rows and columns is fixed when the GridBagLayout object is created. <br />
　　 C. If a component has a fill value of BOTH, then as the container change size, the component is resized. <br />
　　 D. Every component must carry a non-zero weightx and weighty value when it is added to the container <br />
　　 E. If a row has a weighty value that is non-zero, then as the container changes height, the row changes height. </p>
<p>　　 69． Which statement are true about writing a class that is to handle the events issued by a user interface component. <br />
　　 A. Subclassing an adapter is inappropriate in this case. <br />
　　 B. The class should implement some listener interface <br />
　　 C. A class can implement multiple listener interfaces if desired. <br />
　　 D. A subclass of an AWT component cannot listen to its own events. <br />
　　 E. When implements listener interface, a class need only provide those handler methods that it chooses. </p>
<p>　　 70．The argument for a class?s main() method is called args, and the class is invoked as follows. <br />
　　 java Example cat <br />
　　 What would be the effect of trying to access args[0] in the main method? <br />
　　 A. The value produced is cat <br />
　　 B. The value produced is java <br />
　　 C. The value produced is Example <br />
　　 D. An object of type NullPointerException is thrown. <br />
　　 E. An object of type ArrayIndexOutofBoundsException is thrown.<br />
&nbsp;<br />
　　 71． Which best describes the requirements of a fully encapsulated class? <br />
　　 A. Mehtods must not be private. <br />
　　 B. Variables must not be public. <br />
　　 C. The class must be marked final <br />
　　 D. Public methods are all marked final. <br />
　　 E. Modification of the objects state is only possible using method calls. </p>
<p>　　 72．Which contains objects without ordering, duplication, or any particular lookup/retrieval mechanism? <br />
　　 A. Map <br />
　　 B. Set <br />
　　 C. List <br />
　　 D. Collection <br />
　　 E. Enumeration </p>
<p>　　 73．What might cause the current thread to stop executing? <br />
　　 A. An interrupted exception is thrown. <br />
　　 B. The thread execute a sleep() call. <br />
　　 C. The thread constructs a new thread <br />
　　 D. A thread of higher priority becomes ready <br />
　　 E. The thread executes a read() call on InputStream </p>
<p>　　 74．Which statements are true about threads? <br />
　　 A. Threads created from the same class all finish together. <br />
　　 B. A thread can be created only by subclassing java.lang.Thread. <br />
　　 C. Invoking the suspend() method stops a thread so that it cannot be restarted. <br />
　　 D. The Java interpreter?s natural exit occurs when no non-daemon threads remain alive. <br />
　　 E. Uncoordinated changes to shared data by multiple threads may result in the data being read, or left, in an inconsistent state. </p>
<p>　　 75．What might form part of a correct inner class declaration or combined declaration and instantiation? <br />
　　 A. private class C <br />
　　 B. new SimpleInterface(){ <br />
　　 C. new ComplexInterface(x){ <br />
　　 D. private final abstract class( <br />
　　 E. new ComplexClass() implements SimpleInterface</p>
<p>　　 76． Which statements are true about the garbage collection mechanisms? <br />
　　 A. The garbage collection mechanism release memory at pridictable times. <br />
　　 B. A correct program must not depend upon the timing or order of garbage collection <br />
　　 C. Garbage collection ensures that a program will NOT run out of memory during execution <br />
　　 D. The programmer can indicate that a reference through a local variable is no longer going to be used. <br />
　　 E. The programmer has a mechanism that explicitly and immediately frees the memory used by Java objects. <br />
答案及详细分析： <br />
66．D <br />
　　 main()方法是静态方法，静态方法不能直接访问非静态成员。 <br />
67．D <br />
　　 此题考察学生对内部类属性的掌握情况。内部类可以实现接口；匿名类是内部类的一种；内部类通过各种方式可以在包含它的类的外部被访问到；内部类被定义在块中时，只能访问包含它的块的final类型变量。故选择D。 <br />
68．C <br />
　　 此题考察考生对类GridBagLayout、及类GridBagConstraints的掌握情况，请考生查阅API文档。 <br />
69．B、C <br />
　　 此题考察考生对事件处理的理解。D选项是错的，因为控件可以监听自己的事件。另外，当实现一个接口时，必须实现它内部的所有的方法，所以E选项也是错的。 <br />
70．A <br />
　　 命令行参数是紧跟在类名后面的。所以本题中参数由&#8220;cat&#8221;提供。 <br />
71．E <br />
　　 在完全封装类中，一般的定义方式是将所有的成员变量定义为&#8220;private&#8221;，而将访问这些变量的方法定义为非&#8220;private&#8221;类型，这样可以在类的外部间接地访问这些变量。所以E选项是最符合这个意思的。 <br />
72．B <br />
　　 此题考察&#8220;Collection API&#8221;的一些知识。实现接口&#8220;Set&#8221;的类内部所存储的对象是没有顺序，但是允许重复的。另请注意其它几个接口的特征。 <br />
73．A、B、D、E <br />
　　 当新线程被创建时，只是使它变为可运行状态而已，并不能使当前线程停止执行。当调用read()方法时，它与输入输出打交道，可能造成线程的暂停执行。 <br />
74．D、E <br />
　　 程序的执行完毕是以用户线程（user threads）的结束而标志结束的，与超级线程（daemon threads）无关。所以D选项是对的。E选项说明的是当不同线程对相同数据进行访问时，可能造成数据毁损。 <br />
75．A、B <br />
76．B、D <br />
　　 程序的代码是无法对垃圾回收进行精确控制的，程序代码与垃圾回收是相互独立的系统，并不互相影响。答案D告诉我们程序员可以使一个本地变量失去任何意义，例如给本地变量赋值为&#8220;null&#8221;；<br />
</p>
<img src ="http://www.blogjava.net/bily/aggbug/81597.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 20:27 <a href="http://www.blogjava.net/bily/articles/81597.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java经典模拟题（onlyfortrainning）</title><link>http://www.blogjava.net/bily/articles/81580.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 10:12:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81580.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81580.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81580.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81580.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81580.html</trackback:ping><description><![CDATA[
		<p>1.Which statement about the garbage collection mechanism are true?  </p>
		<p>A.Garbage collection require additional program code in cases where multiple threads are running.  </p>
		<p>B.The programmer can indicate that a reference through a local variable is no longer of interest. </p>
		<p>C.The programmer has a mechanism that explicit and immediately frees the memory used by Java objects.  </p>
		<p>D.The garbage collection mechanism can free the memory used by Java Object at expectable time.  </p>
		<p>E.The garbage collection system never reclaims memory from objects while are still accessible to running user threads.  </p>
		<p>
				<br />2. Give the following method:  </p>
		<p>1)public void method( ){  </p>
		<p>2) String a,b;  </p>
		<p>3) a=new String( “hello world” );  </p>
		<p>4) b=new String(“game over” );  </p>
		<p>5) System.out.println(a+b+”ok” );  </p>
		<p>6) a=null;  </p>
		<p>7) a=b;  </p>
		<p>System.out.println(a);  </p>
		<p>9) }  </p>
		<p>In the absence of compiler optimization, which is the earliest point the object a referred is definitely hand to be garbage collection. </p>
		<p>A. before line 3   B.before line 5    C. before line 6    D.before line 7    E. Before line 9  </p>
		<p>
				<br />3. Which statement about listener is true?  </p>
		<p>A.Most component allow multiple listeners to be added.  </p>
		<p>B.If multiple listener be add to a single component, the event only affected one listener.  </p>
		<p>C.Component don' t allow multiple listeners to be add.  </p>
		<p>D.The listener mechanism allows you to call an addXXXListener method as many times as is needed, specifying as many different listeners as your design require.  </p>
		<p>
				<br />4.Give the following code:  </p>
		<p>public class Example{  </p>
		<p>public static void main(String args[] ){  </p>
		<p>int l=0;  </p>
		<p>do{  </p>
		<p>System.out.println(“Doing it for l is:” +l);  </p>
		<p>}while(--l&gt;;0)  </p>
		<p>System.out.println(“Finish” );  </p>
		<p>}  </p>
		<p>}  </p>
		<p>Which well be output:  </p>
		<p>A. Doing it for l is 3   B. Doing it for l is 1   C. Doing it for l is 2  </p>
		<p>D. Doing it for l is 0   E. Doing it for l is –1   F . Finish  </p>
		<p>
				<br />5. Give the code fragment:  </p>
		<p>1)switch(x){  </p>
		<p>2) case 1: System.out.println(“Test 1”);break; </p>
		<p>3) case 2:  </p>
		<p>4) case 3: System.out.println( “ Test 2”);break;  </p>
		<p>5) default: System.out.println(“end” );  </p>
		<p>6) }  </p>
		<p>which value of x would cause “ Test 2” to the output:  </p>
		<p>A. 1   B. 2   C. 3   D. default  </p>
		<p>
				<br />6. Give incompleted method:  </p>
		<p>1)  </p>
		<p>2){if(unsafe()){//do something… }  </p>
		<p>3)else if(safe()){//do the other… }  </p>
		<p>4)}  </p>
		<p>The method unsafe() will throw an IOException, which completes the method of <br />declaration when added at line one?  </p>
		<p>A.public IOException methodName()   B.public void methodName()  </p>
		<p>C.public void methodName() throw IOException  </p>
		<p>D.public void methodName() throws IOException  </p>
		<p>E.public void methodName() throws Exception  </p>
		<p>
				<br />7. Give the code fragment:  </p>
		<p>if(x&gt;;4){  </p>
		<p>System.out.println(“ Test 1”);}  </p>
		<p>else if (x&gt;;9){  </p>
		<p>System.out.println(“ Test 2”);}  </p>
		<p>else {  </p>
		<p>System.out.println(“ Test 3”);}  </p>
		<p>Which range of value x would produce of output “ Test 2”?  </p>
		<p>A. x&lt;4   B. x&gt;;4   C. x&gt;;9   D. None  </p>
		<p>
				<br />8. Give the following method:  </p>
		<p>public void example(){  </p>
		<p>try{  </p>
		<p>unsafe();  </p>
		<p>System.out.println(“Test1”); </p>
		<p>}catch(SafeException e){System.out.println( “ Test 2”);  </p>
		<p>}finally{System.out.println(“ Test 3”);}  </p>
		<p>System.out.println(“ Test 4”);  </p>
		<p>Which will display if method unsafe () run normally?  </p>
		<p>A. Test 1   B. Test 2   C. Test 3   D. Test 4  </p>
		<p>
				<br />9. Which method you define as the starting point of new thread in a class from which new the thread can be execution?  </p>
		<p>A. public void start()    B. public void run()    C. public void int()  </p>
		<p>D. public static void main(String args[])     E. public void runnable()  </p>
		<p>
				<br />10.Given the following class definition:  </p>
		<p>class A{  </p>
		<p>protected int i;  </p>
		<p>A(int i){  </p>
		<p>this.i=i;  </p>
		<p>}  </p>
		<p>}  </p>
		<p>which of the following would be a valid inner class for this class?  </p>
		<p>Select all valid answers:  </p>
		<p>A. class B{ }   B.class B extends A{ }   </p>
		<p>C.class B extends A{ B(){System.out.println(“i=” +i);}  }  </p>
		<p>D.class B{ class A{}  }    E.class A{}<br /><br /><br />11. Which modifier should be applied to a method for the lock of object this to be obtained prior to execution any of the method body?  </p>
		<p>A.  synchronized   B. abstract   C. final   D. static   E. public</p>
		<p>
				<br />12. The following code is entire contents of a file called Example.java,causes precisely one error during compilation:  </p>
		<p>1)class SubClass extends BaseClass{   </p>
		<p>2) }   </p>
		<p>3)class BaseClass(){   </p>
		<p>4) String str;   </p>
		<p>5) public BaseClass(){ </p>
		<p>6) System.out.println( “ok” );}   </p>
		<p>7) public BaseClass(String s){   str=s;}   </p>
		<p>9)}   </p>
		<p>10)public class Example{   </p>
		<p>11) public void method(){   </p>
		<p>12) SubClass s=new SubClass(“hello” );   </p>
		<p>13) BaseClass b=new BaseClass(“world” );   </p>
		<p>14) }   </p>
		<p>15) }   </p>
		<p>Which line would be cause the error?   </p>
		<p>A. 9   B. 10   C. 11   D.12   </p>
		<p>
				<br />13. Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?   </p>
		<p>A. String [] a   B. String a[]   C. char a[][]   D. String a[50]   F. Object a[50]   </p>
		<p>
				<br />14. Give the following java source fragment:   </p>
		<p>//point x   </p>
		<p>public class Interesting{   </p>
		<p>//do something   </p>
		<p>} </p>
		<p>Which statement is correctly Java syntax at point x?   </p>
		<p>A. import java.awt.*;   B.package mypackage;   C. static int PI=3.14   </p>
		<p>D. public class MyClass{//do other thing …}   E. class MyClass{//do something… }</p>
		<p>
				<br />15. Give this class outline:   </p>
		<p>class Example{   </p>
		<p>private int x;   </p>
		<p>//rest of class body…    </p>
		<p>}   </p>
		<p>Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?   </p>
		<p>A. change private int x to public int x   B. change private int x to static int x   </p>
		<p>C. change private int x to protected int x   D. change private int x to final int x   </p>
		<p>
				<br />16. A class design requires that a member variable should be accessible only by same package, which modifier word should be used?   </p>
		<p>A. protected   B. public   C. no modifier   D. private   </p>
		<p>
				<br />17. Which modifier should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?  </p>
		<p>
				<br />18. Which is corrected argument of main() method of application?   </p>
		<p>A. String args   B. String ar[]   C. Char args[][]   D. StringBuffer arg[]   </p>
		<p>
				<br />19.  “The Employee object is a Person, An Employee has appointment store in a vector, <br />a hire date and a number of dependent”    </p>
		<p>short answer: use shortest statement declare a class of Employee.   </p>
		<p>
				<br />20. Give the following class definition inseparate source files:   </p>
		<p>public class Example{   </p>
		<p>public Example(){//do something}   </p>
		<p>protected Example(int i){//do something}   </p>
		<p>protected void method(){//do something}   </p>
		<p>}   </p>
		<p>public class Hello extends Example{//member method and member variable}   </p>
		<p>Which methods are corrected added to the class Hello?   </p>
		<p>A. public void Example(){}   B. public void method(){}   </p>
		<p>C. protected void method(){}   D. private void method(){}   </p>
		<p>
				<br />21. Float s=new Float(0.9F);   </p>
		<p>Float t=new Float(0.9F);   </p>
		<p>Double u=new Double(0.9);   </p>
		<p>Which expression' s result is true?   </p>
		<p>A. s= =t   B. s.equals(t)   C. s= =u   D. t.equals(u) </p>
		<p>
				<br />22. Give following class:   </p>
		<p>class AClass{   </p>
		<p>private long val;   </p>
		<p>public AClass(long v){val=v;}   </p>
		<p>public static void main(String args[]){   </p>
		<p>AClass x=new AClass(10L);   </p>
		<p>AClass y=new AClass(10L);   </p>
		<p>AClass z=y;   </p>
		<p>long a=10L;   </p>
		<p>int b=10;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>Which expression result is true?   </p>
		<p>A. a= =b;   B. a= =x;   C. y= =z;   D. x= =y;    E. a= =10.0;   </p>
		<p>
				<br />23. String s= ”Example String” ;   </p>
		<p>Which operation is legal?   </p>
		<p>A. s&gt;;&gt;;&gt;;=3;   B. int i=s.length();   C. s[3]=“x” ;   </p>
		<p>D. String short_s=s.trim();   E. String t=“root” +s;   </p>
		<p>
				<br />24. What happens when you try to compile and run the following program?   </p>
		<p>class Mystery{   </p>
		<p>String s;   </p>
		<p>public static void main(String[] args){   </p>
		<p>Mystery m=new Mystery();   </p>
		<p>m.go();   </p>
		<p>}   </p>
		<p>void Mystery(){   </p>
		<p>s=”constructor” ;   </p>
		<p>}   </p>
		<p>void go(){   </p>
		<p>System.out.println(s);   </p>
		<p>}   </p>
		<p>}   </p>
		<p>A.this code will not compile   </p>
		<p>B.this code compile but throws an exception at runtime </p>
		<p>C.this code runs but nothing appears in the standard output   </p>
		<p>D.this code runs and  “constructor”  in the standard output   </p>
		<p>E.this code runs and writes ”null”  in the standard output   </p>
		<p>
				<br />25. What use to position a Button in a Frame ,only width of Button is affected by the Frame size, which Layout Button well be set ?  </p>
		<p>A. FlowLayout;   B. GridLayout;   C. North of BorderLayout   </p>
		<p>D. South of BorderLayout   E. East or West of BorderLayout   </p>
		<p>
				<br />26. What use to position a Button in a Frame, size of Button is not affected by the Frame size, which Layout Button will be set?  </p>
		<p>A. FlowLayout;   B. GridLayout;   C. North of BorderLayout   </p>
		<p>D. South of BorderLayout   E. East or West of BorderLayout   </p>
		<p>
				<br />27. Select valid identifier of Java:   </p>
		<p>A. userName   B. %passwd   C. 3d_game   D. $chargeE. this   </p>
		<p>
				<br />28. Which are Java keyword?   </p>
		<p>A. goto   B. null   C. FALSE   D. native   E. const   </p>
		<p>
				<br />29. Give the following java class:   </p>
		<p>public class Example{   </p>
		<p>static int x[]=new int[15]; </p>
		<p>public static void main(String args[]){   </p>
		<p>System.out.println(x[5]);   </p>
		<p>}   </p>
		<p>}   </p>
		<p>Which statement is corrected?   </p>
		<p>A.When compile, some error will occur.     B.When run, some error will occur.   </p>
		<p>C.Output is zero.    D.Output is null.   </p>
		<p>
				<br />30. Give the following java class:   </p>
		<p>public class Example{   </p>
		<p>public static void main(String args[]){   </p>
		<p>static int x[] = new int[15];   </p>
		<p>System.out.println(x[5]);   </p>
		<p>}   </p>
		<p>}   </p>
		<p>Which statement is corrected?   </p>
		<p>A.When compile, some error will occur.    B.When run, some error will occur.   </p>
		<p>C.Output is zero.    D.Output is null.   </p>
		<p>
				<br />31. Short answer:   </p>
		<p>The decimal value of i is 12, the octal i value is:   </p>
		<p>
				<br />32. Short answer:   </p>
		<p>The decimal value of i is 7, the hexadecimal i value is:   </p>
		<p>
				<br />33. Give the following class:   </p>
		<p>public class Example{   </p>
		<p>String str=new String( “good” );   </p>
		<p>char ch[]={‘a’,’b’,’c’ };   </p>
		<p>public static void main(String args[]){ </p>
		<p>Example ex=new Example();   </p>
		<p>ex.change(ex.str,ex.ch);   </p>
		<p>System.out.println(ex.str+ ”and” +ex.ch[0] +ex.ch[1] +ex.ch[2]);   </p>
		<p>}   </p>
		<p>public void change(String str,char ch[]){   </p>
		<p>str=”test ok”;ch[0]=’g’ ;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>Which is the output:   </p>
		<p>A. good and abc   B. good and gbc   C. test ok and abc   D. test ok and gbc   </p>
		<p>
				<br />34. Which code fragments would correctly identify the number of arguments passed via command line to a Java application, exclude the name of the class that is being invoke.   </p>
		<p>A. int count = args.length;   B. int count = args.length-1;   </p>
		<p>C. int count=0;  while(args[count]!=null)  count++;   </p>
		<p>D. int count=0;while   (!(args[count].equals(“” )))   count++;   </p>
		<p>
				<br />35. FilterOutputStream is the parent class for BufferedOutputStream, DataOutputStream and PrintStream. Which classes are valid argument for the constructor of a FilterOutputStream?   </p>
		<p>A. InputStream   B. OutputStream   C. File   D. RandomAccessFile    E. StreamTokenizer   </p>
		<p>
				<br />36. Given this skeleton of a class currently under construction: </p>
		<p>public class Example{   </p>
		<p>int x,y,z;   </p>
		<p>public Example (int a, int b) {   </p>
		<p>//lots of complex computation   </p>
		<p>x=a; y=b;   </p>
		<p>}   </p>
		<p>public Example(int a, int b, int c){   </p>
		<p>// do everything the same as single argument   </p>
		<p>// version of constructor   </p>
		<p>// including assignment x=a, y=b, z=c   </p>
		<p>z=c;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the most concise way to code the  “do everything…”  part of the constructor taking two arguments?   <br /><br />Short answer:   </p>
		<p>
				<br />37. Which correctly create a two dimensional array of integers?   </p>
		<p>A.int a[][] = new int[][];    B.int a[10][10] = new int[][];    C.int a[][] = new int[10][10];   </p>
		<p>D.int [][]a = new int[10][10];    E.int []a[] = new int[10][10];   </p>
		<p>
				<br />38. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java?   </p>
		<p>A.public class Fred{   </p>
		<p>public int x = 0;   </p>
		<p>public Fred (int x){ </p>
		<p>this.x=x;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>B.public class fred{   </p>
		<p>public int x = 0;   </p>
		<p>public Fred (int x){   </p>
		<p>this.x=x;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>C.public class Fred extends MyBaseClass, MyOtherBaseClass{   </p>
		<p>public int x = 0;   </p>
		<p>public Fred(int xval){   </p>
		<p>x=xval;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>D.protected class Fred{   </p>
		<p>private int x = 0;   </p>
		<p>private Fred (int xval){   </p>
		<p>x=xval;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>E.import java.awt.*;   </p>
		<p>public class Fred extends Object{   </p>
		<p>int x;   </p>
		<p>private Fred(int xval){   </p>
		<p>x = xval;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>
				<br />39. A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same package. What should be done to achieve this?   </p>
		<p>A.The variable should be marked public    B.The variable should be marked private   </p>
		<p>C.The variable should be marked protected    D.The variable should have no special access modifier   </p>
		<p>E.The variable should be marked private and an accessible method provided </p>
		<p>
				<br />40. Which correctly create an array of five empty Strings?   </p>
		<p>A.String a[] = new String[5];   for (int i=0;i&lt;5;a[i++]= ”” );   </p>
		<p>B.String a []={“”,””,””,””,”” };   </p>
		<p>C.String a[5];   D.String [5] a;   E.String [] a = new String[5];   for (int i = 0 ;i&lt;5;a[i++] = null);   </p>
		<p>
				<br />41. Which cannot be added to a Container?   </p>
		<p>A. an Applet   B. a Component   C. a Container   D. a MenuComponent   E. a panel   </p>
		<p>
				<br />42. Which is the return value of Event listener' s method?   </p>
		<p>A. String   B. AWTEvent   C. void   D. int   </p>
		<p>
				<br />43. If we implements MouseListener, which is corrected argument of its method? (short answer)   </p>
		<p>
				<br />44. Use the operator “&gt;;&gt;;” and “&gt;;&gt;;&gt;;” . Which statement is true?   </p>
		<p>A.1010 0000 0000 0000 0000 0000 0000 0000 &gt;;&gt;; 4 give   </p>
		<p>0000 1010 0000 0000 0000 0000 0000 0000   </p>
		<p>B.1010 0000 0000 0000 0000 0000 0000 0000 &gt;;&gt;; 4 give </p>
		<p>1111 1010 0000 0000 0000 0000 0000 0000   </p>
		<p>C.1010 0000 0000 0000 0000 0000 0000 0000 &gt;;&gt;;&gt;; 4 give   </p>
		<p>0000 1010 0000 0000 0000 0000 0000 0000   </p>
		<p>D.1010 0000 0000 0000 0000 0000 0000 0000 &gt;;&gt;;&gt;; 4 give   </p>
		<p>1111 1010 0000 0000 0000 0000 0000 0000   </p>
		<p>
				<br />45. Give following fragment.   </p>
		<p>Outer: for(int i=0; i&lt;3; i++)   </p>
		<p>inner:for(int j=0;j&lt;3;j++){   </p>
		<p>If(j&gt;;1)break outer;   </p>
		<p>System.out.println(j+ ”and” +i);   </p>
		<p>}   </p>
		<p>Which will be output?   </p>
		<p>A. 0 and 0   B. 0 and 1   C. 0 and 2   D. 0 and 3   </p>
		<p>E. 1 and 0   F. 1 and 1   G. 1 and 2   H. 1 and 3   </p>
		<p>I. 2 and 0     J. 2 and 1   K. 2 and 2   L. 2 and 3   </p>
		<p>
				<br />46. Examine the following code which includes an inner class:   </p>
		<p>public final class Test4 implements A{   </p>
		<p>class Inner{   </p>
		<p>void test(){   </p>
		<p>if (Test4.this.flag);{   </p>
		<p>sample();   </p>
		<p>}   </p>
		<p>}   </p>
		<p>private boolean flag=false;   </p>
		<p>}   </p>
		<p>public void sample(){   </p>
		<p>System.out.println(“Sample”); </p>
		<p>}   </p>
		<p>public Test4(){   </p>
		<p>(new Inner()).test();   </p>
		<p>}   </p>
		<p>public static void main(String args[]){   </p>
		<p>new Test4();   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result:   </p>
		<p>A.Print out  “Sample”   B.Program produces no output but terminates correctly.   </p>
		<p>C. Program does not terminate.    D.The program will not compile   </p>
		<p>
				<br />47. What is written to the standard output given the following statement:   </p>
		<p>System.out.println(4|7);   </p>
		<p>Select the right answer:   </p>
		<p>A.4   B.5   C.6   D.7   E.0   </p>
		<p>
				<br />48. Look the inheritance relation:   </p>
		<p>person   </p>
		<p>|   </p>
		<p>----------------</p>
		<p>| |   </p>
		<p>man woman   </p>
		<p>In a source of java have the following line:   </p>
		<p>person p=new man();   </p>
		<p>What statement are corrected?   </p>
		<p>A.The expression is illegal.  B.Compile corrected but running wrong.   </p>
		<p>C.The expression is legal.   D.Will construct a person' s object.   </p>
		<p>
				<br />49. Look the inheritance relation:   </p>
		<p>person   </p>
		<p>|   </p>
		<p>---------------- </p>
		<p>| |   </p>
		<p>man woman   </p>
		<p>In a source of java have the following line:   </p>
		<p>woman w=new man():   </p>
		<p>What statement are corrected?   </p>
		<p>A.The expression is illegal.    B.Compile corrected but running wrong.   </p>
		<p>C.The expression is legal.     D.Will construct a woman' s object.   </p>
		<p>
				<br />50.Which can NOT be used in declaring or declaring and initializing an automatic (method local) variable?  </p>
		<p>A. final   B. static C. expressions D. Constants of non-primitive type   </p>
		<p>E.initialized arrays (such as “ {“Hello”,”Good bye”}” ).   </p>
		<p>
				<br />51. Given the following incomplete method:   </p>
		<p>public void method(){   </p>
		<p>1)if (someTestFails()){   </p>
		<p>2)   </p>
		<p>3) }   </p>
		<p>4)   </p>
		<p>5)}   </p>
		<p>You want to make this method throw an IOException if,and only if,the method someTestFails() returns a value of true.   </p>
		<p>Which changes achieve this?   </p>
		<p>A.Add at line 2:IOException e;    B.Add at line 4:throw e;   </p>
		<p>C.Add at line 4:throw new IOException();    D.Add at line 6:throw new IOException();  </p>
		<p>E.Modify the method declaration to indicate that an object of type Exception might be thrown.   </p>
		<p>
				<br />52.Given the following definition:   </p>
		<p>String s = null;   </p>
		<p>Which code fragments cause an object of type NullPointerException to be thrown?   </p>
		<p>A. if((s!=null)&amp;(s.length()&gt;;0))     B. if((s!=null)&amp;&amp;(s.length()&gt;;0))   </p>
		<p>C. if((s==null)|(s.length()==0))    D. if((s==null)||(s.length()==0))   </p>
		<p>
				<br />53.The following is a program   </p>
		<p>1)class Exsuper{   </p>
		<p>2) String name;   </p>
		<p>3) String nick_name;   </p>
		<p>4)   </p>
		<p>5) public ExSuper(String s,String t){   </p>
		<p>6) name = s;   </p>
		<p>7) nick_name = t;   </p>
		<p>}   </p>
		<p>9)   </p>
		<p>10)public string toString(){   </p>
		<p>11) return name;   </p>
		<p>12) }   </p>
		<p>13)}   </p>
		<p>14)   </p>
		<p>15)public class Example extends ExSuper{   </p>
		<p>16)   </p>
		<p>17)public Example(String s,String t){   </p>
		<p>1 super(s,t);   </p>
		<p>19)}   </p>
		<p>20)   </p>
		<p>21)public String to String(){   </p>
		<p>22) return name + ”a.k.a” +nick_name;   </p>
		<p>23)}   </p>
		<p>24)   </p>
		<p>25)public static void main(String args[]){  </p>
		<p>26) ExSuper a = new ExSuper( “First”,”1st” );   </p>
		<p>27) ExSuper b = new Example(“Second”,”2nd” );   </p>
		<p>2   </p>
		<p>29)System.out.println(“a is” +a.toString());   </p>
		<p>30)System.out.println(“b is” +b.toString());   </p>
		<p>31) }   </p>
		<p>32)}   </p>
		<p>
				<br />54.What happens when the user attempts to compile and run this program?   </p>
		<p>A. A Compiler error occurs at line 21  <br /><br />B. An object of type ClassCastException is thrown at line 27   </p>
		<p>C.The following output:   </p>
		<p>a is First   </p>
		<p>b is second   </p>
		<p>D. The following output:   </p>
		<p>a is First   </p>
		<p>b is Second a.k.a 2nd   </p>
		<p>E.The following output:   </p>
		<p>a is First a.k.a 1st   </p>
		<p>b is Second a.k.a 2nd   </p>
		<p>
				<br />55.Which statements are true about Listeners?   </p>
		<p>A.At most one listener can be added to any simple Component.   </p>
		<p>B.The return value from a listener is used to control the invocation of other listener   </p>
		<p>C.If multiple listeners are added to a single component, they must all be made friends to each other </p>
		<p>D.If multiple listeners are added to single component, the order of invocation of the listener is not specified.   </p>
		<p>E.In the AWT, listener methods generally take an argument, which is an instance of some subclass of java.awt.AWTEvent class.   </p>
		<p>
				<br />56.Given the following class outline:   </p>
		<p>class Example{   </p>
		<p>private int x;   </p>
		<p>// rest of class body   </p>
		<p>public static void main(String args[]){   </p>
		<p>//implementation of main mehtod}   </p>
		<p>}   </p>
		<p>Which statement is true?   </p>
		<p>A.x=2 is a valid assignment in the main() method of class Example.   </p>
		<p>B.Changing private int x to int x would make x=2 a valid assignment in the main() method of class Example.   </p>
		<p>C.Changing private int x to public int x would make x=2 a valid assignment in the main() method of class Example.   </p>
		<p>D.Changing private int x to static int x would make x=2 a valid assignment in the main() method of class Example.   </p>
		<p>E.Changing class Example to public class Example would make x=2 a valid assignment in the main() method of class Example. </p>
		<p>
				<br />57.Which statement is true about an inner class?   </p>
		<p>A.It must be anonymous    B.It can not implement an interface   </p>
		<p>C.It is only accessible in the enclosing class   </p>
		<p>D.It can access any final variables in any enclosing scope.   </p>
		<p>
				<br />58.Which statement is true about the grid bag layout manager?   </p>
		<p>A.The number of rows and columns is fixed when the container is created.   </p>
		<p>B.The number of rows and columns is fixed when the GridBagLayout object is created.   </p>
		<p>C.If a component has a fill value of BOTH, then as the container change size, the component is resized.  </p>
		<p>D.Every component must carry a non-zero weightx and weighty value when it is added to the container   </p>
		<p>E.If a row has a weighty value that is non-zero, then as the container changes height, the row changes height.   </p>
		<p>
				<br />59.Which statement are true about writing a class that is to handle the events issued by a user interface component.   </p>
		<p>A.Subclassing an adapter is inappropriate in this case. </p>
		<p>B.The class should implement some listener interface   </p>
		<p>C.A class can implement multiple listener interfaces if desired.   </p>
		<p>D.A subclass of an AWT component cannot listen to its own events.   </p>
		<p>E.When implements listener interface, a class need only provide those handler methods that it chooses.   </p>
		<p>
				<br />60.Which best describes the requirements of a fully encapsulated class?   </p>
		<p>A.Methods must not be private.    B.Variables must not be public.   </p>
		<p>C.The class must be marked final    D.Public methods are all marked final.   </p>
		<p>E.Modification of the objects state is only possible using method calls.   </p>
		<p>
				<br />61.Which contains objects without ordering, duplication, or any particular lookup/retrieval mechanism?   </p>
		<p>A. Map   B. Set   C. List   D. Collection   E. Enumeration   </p>
		<p>
				<br />62.What might cause the current thread to stop executing?   </p>
		<p>A.An interrupted exception is thrown.     B.The thread execute a sleep() call.   </p>
		<p>C.The thread constructs a new thread    D.A thread of higher priority becomes ready </p>
		<p>E.The thread executes a read() call on InputStream   </p>
		<p>
				<br />63.Which statements are true about threads?   </p>
		<p>A.Threads created from the same class all finish together.   </p>
		<p>B.A thread can be created only by subclassing java.lang.Thread.   </p>
		<p>C.Invoking the suspend() method stops a thread so that it cannot be restarted.   </p>
		<p>D.The Java interpreter ’ s natural exit occurs when no non-daemon threads remain alive.   </p>
		<p>E.Uncoordinated changes to shared data by multiple threads may result in the data being read, or left, in an inconsistent state.   </p>
		<p>64.What might FORM part of a correct inner class declaration or combined declaration and instantiation?   </p>
		<p>A.private class C   B.new SimpleInterface(){   </p>
		<p>C.new ComplexInterface(x){   D.private final abstract class(   </p>
		<p>E.new ComplexClass() implements SimpleInterface   </p>
		<p>
				<br />65. Which statements are true about the garbage collection mechanisms?   </p>
		<p>A.The garbage collection mechanism release memory at pridictable times.   </p>
		<p>B.A correct program must not depend upon the timing or order of garbage collection </p>
		<p>C.Garbage collection ensures that a program will NOT run out of memory during execution   </p>
		<p>D.The programmer can indicate that a reference through a local variable is no longer going to be used.  </p>
		<p>E.The programmer has a mechanism that explicitly and immediately frees the memory used by Java objects.   </p>
		<p>
				<br />66. Given:   </p>
		<p>public class ReturnIt{   </p>
		<p>ReturnType methodA(byte x,double y){   </p>
		<p>return (short)x/y*2;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the valid return for methodA in line2?   </p>
		<p>A.int    B. byte    C. long    D. short    E. float    F. double </p>
		<p>
				<br />67. Given:   </p>
		<p>abstract class AbstractIt{   </p>
		<p>abstract float getFloat();   </p>
		<p>}   </p>
		<p>public class AbstractTest extends AbstractIt{   </p>
		<p>private float f1 = 1.0f;   </p>
		<p>private float getFloat(){retrun f1;}   </p>
		<p>What is the result?   </p>
		<p>A.Compilation is successful    B.An error on line 6 causes a runtime failure   </p>
		<p>C.An error at line 6 causes compilation to fail    D.An error at line 2 causes compilation to fail</p>
		<p>
				<br />68.Which declaration prevents creating a subclass of an outer class?   </p>
		<p>A.static class FooBar{}  B.private class FooBar{}  C.abstract class FooBar{}   </p>
		<p>D.final public class FooBar{}   E.final abstract class FooBar{}   </p>
		<p>
				<br />69.Given:   </p>
		<p>byte[] array1,array2[];   </p>
		<p>byte array3[][];   </p>
		<p>byte [][] array4;   </p>
		<p>if each array has been initialized, which statement will cause a compiler error?   </p>
		<p>A.array2 = array1    B.array2=array3   C.array2=array4   </p>
		<p>D.both A and B   E.both A and C  F.both B and C   </p>
		<p>
				<br />70.   </p>
		<p>public class Test{   </p>
		<p>public int aMethod(){   </p>
		<p>static int i=0;   </p>
		<p>i++;   </p>
		<p>return i;   </p>
		<p>}   </p>
		<p>public static void main(String args[]){   </p>
		<p>Test test = new Test();   </p>
		<p>test.aMethod();   </p>
		<p>int j=test.aMethod();   </p>
		<p>System.out.println(j);   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.Compilation will fail   B.Compilation will succeed and the program will print ”0”. </p>
		<p>C.Compilation will succeed and the program will print ”1” .   </p>
		<p>D.Compilation will succeed and the program will print”2” .   </p>
		<p>
				<br />71.You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access modifier that will accomplisher this objective?   </p>
		<p>A.public    B.private    C.protected    D.transient    E. No access modifier is qualified   </p>
		<p>
				<br />72.class Super{   </p>
		<p>public int i=0;   </p>
		<p>public Super(String text){   </p>
		<p>i=1;}   </p>
		<p>}   </p>
		<p>public class Sub extends Super{   </p>
		<p>public Sub(String text){   </p>
		<p>i=2;   </p>
		<p>}   </p>
		<p>public static void main(String ag[]){   </p>
		<p>Sub sub=new Sub(“Hello” );   </p>
		<p>System.out.println(sub.i);   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.Compilation will fail   B.Compilation will succeed and the program will print”0” .   </p>
		<p>C.Compilation will succeed and the program will print”1”    </p>
		<p>D.Compilation will succeed and the program will print”2”    </p>
		<p>
				<br />73. Given:   </p>
		<p>class Super{   </p>
		<p>public float getNum(){return 3.0f;}</p>
		<p>}   </p>
		<p>public class Sub extends Super{ }   </p>
		<p>Which method , placed at line 6,will cause a complier error?   </p>
		<p>A.public float getNum(){return 4.0f;}    B.public void getNum(){}   </p>
		<p>C.public void getNum(double d){}   D.public double getNum(float d){return 4.0d;}   </p>
		<p>
				<br />74. public class Test{   </p>
		<p>public static void main(String args[]){   </p>
		<p>int i=0;   </p>
		<p>while(1){   </p>
		<p>if(i==4){   </p>
		<p>break;   </p>
		<p>}   </p>
		<p>i++;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the value of i at line 10?   </p>
		<p>A.0   B.3   C.4   D.5   E.The code will not compile   </p>
		<p>
				<br />75.Given:   </p>
		<p>int i=1,j=10;   </p>
		<p>do{   </p>
		<p>if(i++&gt;;--j) continue;   </p>
		<p>}while(i&lt;5);   </p>
		<p>After execution, what are the values for i and j?   </p>
		<p>A.i=6 and j=5   B.i=5 and j=5   C.i=6 and j=4   D.i=5 and j=6   E.i=6 and j=6   </p>
		<p>
				<br />76.Given:   </p>
		<p>public class IfElse{   </p>
		<p>public static void main(String args[]){ </p>
		<p>if(odd(5))   </p>
		<p>System.out.println( “odd” );   </p>
		<p>else   </p>
		<p>System.out.println(“Even” );   </p>
		<p>}   </p>
		<p>public static int odd(int x){return x%2;}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.The output is odd;    B. The output is even;   C.An error on line 3 causes compilation to fail </p>
		<p>D.An error on line 8 causes compilation to fail   </p>
		<p>
				<br />77.   </p>
		<p>import java.io.IOException;   </p>
		<p>public class ExceptionTest{   </p>
		<p>public static void main(String[] args){   </p>
		<p>try{   </p>
		<p>methodA();   </p>
		<p>}catch(IOException e){   </p>
		<p>System.out.println(“Caught IOException” );   </p>
		<p>}catch(Exception e){   </p>
		<p>System.out.println(“Caught Exception” );   </p>
		<p>}   </p>
		<p>}   </p>
		<p>public static void methodA(){   </p>
		<p>throw new IOException();   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.The code will not compile;   B.The output is Caught Exception   </p>
		<p>C.The output is Caught IOException   D.The program executes normally without printing a message   </p>
		<p>
				<br />78.   </p>
		<p>public class Test{  </p>
		<p>public static String output =  “” ;   </p>
		<p>public static void foo(int i){   </p>
		<p>try{   </p>
		<p>if(i==1){   </p>
		<p>throw new Exception();   </p>
		<p>}   </p>
		<p>output += “1” ;   </p>
		<p>}   </p>
		<p>catch(Exception e){   </p>
		<p>output += “2” ;   </p>
		<p>return;   </p>
		<p>}   </p>
		<p>finally{   </p>
		<p>output += “3” ;   </p>
		<p>}   </p>
		<p>output += “4” ;   </p>
		<p>}   </p>
		<p>public static void main(String args[]){   </p>
		<p>foo(0);   </p>
		<p>foo(1);   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the value of the variable output at line 24?   </p>
		<p>Shortanswer:   </p>
		<p>
				<br />79.Given:   </p>
		<p>public class Foo{   </p>
		<p>public static void main(String[] args){   </p>
		<p>try{return;}   </p>
		<p>finally{System.out.println(“Finally” );}   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.The program runs and prints nothing.   B.The program runs and prints “Finally” ;   </p>
		<p>C.The code compiles, but an exception is thrown at runtime.   </p>
		<p>D.The code will not compile because the catch block is missing.   </p>
		<p>
				<br />80.Given </p>
		<p>public class IfTest{   </p>
		<p>public static void main(String [] s){   </p>
		<p>int x=3;   </p>
		<p>int y=1;   </p>
		<p>if(x=y)   </p>
		<p>System.out.println( “Not equal” );   </p>
		<p>else   </p>
		<p>System.out.println(“Equal” );   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.The output is “Equal”.   B.The output is “Not equal”    </p>
		<p>C.An error at line 5 causes compilation to fail   </p>
		<p>D.The program executes but does not print a message   </p>
		<p>
				<br />81.Given   </p>
		<p>public class X{   </p>
		<p>public Object m(){   </p>
		<p>Object o = new Float(3.14F);   </p>
		<p>Object [] oa = new Object[1];   </p>
		<p>oa[0] = o;   </p>
		<p>o=null;   </p>
		<p>return oa[0];   </p>
		<p>}   </p>
		<p>}   </p>
		<p>When is the Float object, created in line 3,eligible for garbage collection?   </p>
		<p>A.just after line 5   B.just after line 6   </p>
		<p>C.just after line 7(that is,as the method returns)    D.never in this method   </p>
		<p>
				<br />82.Which two are reserved words in Java?(2)   </p>
		<p>A.run    B. import    C. default    D. implement   </p>
		<p>public class IfTest{   </p>
		<p>public static void main(String [] s){   </p>
		<p>int x=3;   </p>
		<p>int y=1;   </p>
		<p>if(x=y)   </p>
		<p>System.out.println( “Not equal” );   </p>
		<p>else   </p>
		<p>System.out.println(“Equal” );   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.The output is “Equal”.   B.The output is “Not equal”    </p>
		<p>C.An error at line 5 causes compilation to fail   </p>
		<p>D.The program executes but does not print a message   </p>
		<p>
				<br />83.Which two are reserved words in Java?(2)   </p>
		<p>A.run    B. import    C. default    D. implement </p>
		<p>PrintWriter out = new PrintWriter(new  java.io.OutputStreamWriter(System.out),true);   </p>
		<p>out.println( “Hello” );   </p>
		<p>}   </p>
		<p>}   </p>
		<p>Which statement at Point X on line 1 allows this code to compile and run?   </p>
		<p>A.import java.io.PrintWriter;   B.include java.io.PrintWriter;   </p>
		<p>C.import java.io.OutputStreamwriter;   D.include java.io.OutputStreamWriter;   </p>
		<p>E.No statement is needed   </p>
		<p>
				<br />86.Which three are valid declarations of a float?(3)   </p>
		<p>A.float foo = -1;   B.float foo = 1.0;    C.float foo = 42e1;   </p>
		<p>D.float foo = 2.02f;   E.float foo = 3.03d;    F.float foo = 0x0123;.   </p>
		<p>
				<br />87.   </p>
		<p>interface Foo{   </p>
		<p>int k=0;   </p>
		<p>}   </p>
		<p>public class Test implements Foo{   </p>
		<p>public static void main(String args[]){   </p>
		<p>int i;   </p>
		<p>Test test = new Test();   </p>
		<p>i=test.k;   </p>
		<p>i=Test.k;   </p>
		<p>i=Foo.k;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>A.Compilation succeeds.   B.An error at line 2 causes compilation to fail.   </p>
		<p>C.An error at line 9 causes compilation to fail.    D.An error at line 10 causes compilation to fail.   </p>
		<p>E.An error at line 11 causes compilation to fail. </p>
		<p>
				<br />88.   </p>
		<p>public class Foo{   </p>
		<p>public static void main(String sgf[]){   </p>
		<p>StringBuffer a = new StringBuffer("A");   </p>
		<p>StringBuffer b = new StringBuffer("B");   </p>
		<p>operate(a,b);   </p>
		<p>System.out.println(a+","+b);   </p>
		<p>}   </p>
		<p>static void operate(StringBuffer x,StringBuffer y){   </p>
		<p>x.append(y);   </p>
		<p>y=x;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the result?   </p>
		<p>A.The code compiles and prints  “A.B”.   B.The code compiles and prints “A.A”.   </p>
		<p>C.The code compiles and prints “B.B”.    D.The code compiles and prints “AB.B”.   </p>
		<p>E.The code compiles and prints “AB.AB”.   </p>
		<p>
				<br />89.Given   </p>
		<p>public class Test{   </p>
		<p>public static void main(String sss[]){   </p>
		<p>int i=0xFFFFFFF1;   </p>
		<p>int j=~i;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>What is the value decimal value of j at line 5?   </p>
		<p>A.0    B.1    C.14    D.-15   F.An error at line 3 causes compilation to fail </p>
		<p>G.An error at line 4 causes compilation to fail   </p>
		<p>
				<br />90. Which two demonstrate an  “is a”  relationship?(2)   </p>
		<p>A.public interface Person{}   </p>
		<p>public class Employee extends Person{}   </p>
		<p>B.public interface Shape{}   </p>
		<p>public interface Retangle extends Shape{}   </p>
		<p>C.public interface Color{}   </p>
		<p>public class Shape{private Color color;}   </p>
		<p>D.public class Species{}   </p>
		<p>public class Animal{private Species species;}   </p>
		<p>E.interface Component{}   </p>
		<p>class Container implements Component{   </p>
		<p>private Component [] children;   </p>
		<p>}   </p>
		<p>
				<br />91.Given   </p>
		<p>Package foo;   </p>
		<p>public class Outer{   </p>
		<p>public static class Inner{   </p>
		<p>}   </p>
		<p>}   </p>
		<p>Which statement is true?   </p>
		<p>A.An instance of the Inner class can be constructed with “ new Outer.Inner():   </p>
		<p>B.An instance of the Inner class cannot be constructed outside of package foo;   </p>
		<p>C.An instance of the Inner class can only be constructed from within the Outer class.   </p>
		<p>D.From within the package bar, an instance of the Inner class can be constructed with “new Inner()”.   </p>
		<p>
				<br />92.Which statement is true?   </p>
		<p>A.An anonymous inner class may be declared as final.   </p>
		<p>B.An anonymous inner class can be declared as private.   </p>
		<p>C.An anonymous inner class can implement multiple interfaces .   </p>
		<p>D.An anonymous inner class can access final variables in any enclosing scope.   </p>
		<p>E.Construction of an instance of a static inner class requires an instance of the enclosing outer class.   </p>
		<p>
				<br />93.Which statement is true?   </p>
		<p>A.If only one thread is blocked in the wait method of an object, and another thread executes the notify method on that same object , then the first thread immediately resumes execution.   </p>
		<p>B.If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution.   </p>
		<p>C.If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call. </p>
		<p>D.If two threads are blocked in the wait method of one object , and another thread executes the notify method on the same object, then the thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call.   </p>
		<p>
				<br />94. You are assigned the task of building a Panel containing a TextArea at the top, a Label directly below it, and a Button directly Below the Label. If the three components are added directly to the Panel, which layout manager can the Panel use to ensure that the TextArea absorbs all of the free vertical space when the Panel is resized?   </p>
		<p>A.GridLayout    B. FlowLayout    C. GridBagLayout    D. CardLayout    E. BorderLayout </p>
		<p>
				<br />95. Given:   </p>
		<p>String foo = ”ABCDE”    </p>
		<p>foo.substring(3);   </p>
		<p>foo.concat(“XYZ” );   </p>
		<p>What is the value of the variable foo at line 4?   </p>
		<p>Shortanswer:   </p>
		<p>
				<br />96. Which statement about static inner classes is true?   </p>
		<p>A.An anonymous class can be declared as static   </p>
		<p>B.A static inner class cannot be a static member of the outer class</p>
		<p>C.A static inner class does not require an instance of the enclosing class   </p>
		<p>D.Instance members of a static inner class can be referenced using the class name of the static inner class   </p>
		<p>
				<br />97. Which statement is true for the class java.util.ArrayList?   </p>
		<p>A.The elements in the collection are ordered.    B.The collection is guaranteed to be immutable   </p>
		<p>C.The elements in the collection are guaranteed to be unique   </p>
		<p>D.The elements in the collection are accessed using a unique key   </p>
		<p>E.The elements in the collection are guaranteed to be synchronized   </p>
		<p>
				<br />98. Which two cannot directly cause a thread to stop executing?   </p>
		<p>A.exiting from a synchronized block    B.calling the wait method on an object   </p>
		<p>C.calling the notify method on an object    D.calling a read method on an InputStream object   </p>
		<p>E.calling the setPriority method on a thread object   </p>
		<p>
				<br />99. Given:   </p>
		<p>public class SyncTest{   </p>
		<p>private int x;   </p>
		<p>private int y; </p>
		<p>public void setX(int I){x=I;}   </p>
		<p>public void setY(int I){y=I;}   </p>
		<p>public synchronized void setXY(int I){setX(i);setY(i);}   </p>
		<p>public synchronized boolean check(){return x != y;}   </p>
		<p>}   </p>
		<p>Under which conditions will check() return true when called from a different class?   </p>
		<p>A.check() can never return true   </p>
		<p>B.check()can return true when setXY is called by multiple threads   </p>
		<p>C.check()can return true when multiple threads call setX and setY separately.   </p>
		<p>D.check() can only return true if SynchTest is changed to allow x and y to be set separately.   </p>
		<p>
				<br />100. class A implements Runnable{   </p>
		<p>int i;   </p>
		<p>public void run(){   </p>
		<p>try{   </p>
		<p>Thread.sleep(50000);   </p>
		<p>i=10;   </p>
		<p>}catch(InterruptedException e){}   </p>
		<p>}   </p>
		<p>}   </p>
		<p>public class Test{   </p>
		<p>public static void main(String a[]){   </p>
		<p>try{   </p>
		<p>A a = new A();   </p>
		<p>Thread t = new Thread(a);   </p>
		<p>t.start();   </p>
		<p>int j=a.i;   </p>
		<p>}catch(Exception e){}   </p>
		<p>}   </p>
		<p>} </p>
		<p>Which statement at line 17 will ensure that j=10 at line 19?   </p>
		<p>A.a.wait();   B.t.wait();   C.t.join();    D.t.yield();    E.t.notify();    F.a.notify();    G.t.interrupt();   </p>
		<p>
				<br />101. 1.class EnclosingOne{   </p>
		<p>2. public class InsideOne{}   </p>
		<p>3. }   </p>
		<p>4. public class InnerTest{   </p>
		<p>5. public static void main(String []args){   </p>
		<p>6. EnclosingOne eo=new EnclosingOne();   </p>
		<p>7. //insert code here   </p>
		<p>8. }   </p>
		<p>9. }   </p>
		<p>Which statement at line 7 constructs an instance of the inner class?   </p>
		<p>A.InsideOne ei=eo.new InsideOne();   B.eo.InsideOne ei=eo.new InsideOne();   </p>
		<p>C.InsideOne ei=EnclosingOne.new InsideOne();    D.EnclosingOne. InsideOne ei=eo.new InsideOne();   </p>
		<p>
				<br />102.Which method is an appropriate way to determine the cosine of 42 degrees?   </p>
		<p>A.double d=Math.cos(42);    B.double d=Math.cosine(42);    C.double d=Math.cos(Math.toRadians(42));   </p>
		<p>D.double d=Math.cos(Math.toDegrees(42));    E.double d=Math.cosine(Math.toRadians(42));   </p>
		<p>
				<br />103.Which is a method of the MouseMotionListener interface?  </p>
		<p>A.public void mouseMoved(MouseEvent)    B.public boolean mouseMoved(MouseEvent)   </p>
		<p>C.public void mouseMoved(MouseMotionEvent)    D.public boolean MouseMoved(MouseMotionEvent)   </p>
		<p>E.public boolean mouseMoved(MouseMotionEvent)   </p>
		<p>
				<br />104.Which statement is true for the class java.util.HashSet?   </p>
		<p>A.The elements in the collection are ordered.   B.The collection is guaranteed to be immutable.   </p>
		<p>C.The elements in the collection are guaranteed to be unique.   </p>
		<p>D.The elements in the collection are accessed using a unique key.   </p>
		<p>E.The elements in the collection are guaranteed to be synchronized.   </p>
		<p>
				<br />105. 1. public class Test{   </p>
		<p>2. public static void add3(Integer i){   </p>
		<p>3. int val=i.intvalue();   </p>
		<p>4. val+=3;   </p>
		<p>5. i=new Integer(val);   </p>
		<p>6. }   </p>
		<p>7.   </p>
		<p>8. public static void main(String []args){   </p>
		<p>9. Integer i=new Integer(0);   </p>
		<p>10. add3(i);   </p>
		<p>11. System.out.println(i.intvalue());   </p>
		<p>12. }   </p>
		<p>13. }   </p>
		<p>What is the result?   </p>
		<p>A.Compilation will fail.   B.The program prints  “0”.   C.The program prints “3” .   </p>
		<p>D.Compilation will succeed but an exception will be thrown at line 3.   </p>
		<p>
				<br />106.Given:   </p>
		<p>1. public class Test{   </p>
		<p>2. public static void main(String []args){   </p>
		<p>3. System.out.println(6^3);   </p>
		<p>4. }   </p>
		<p>5. }   </p>
		<p>What is the output?   </p>
		<p>Answer:   </p>
		<p>
				<br />107.Which will declare a method that forces a subclass to implement it?   </p>
		<p>A.public double methoda();   B.static void methoda(double d1){}    C.public native double methoda();   </p>
		<p>D.abstract public void methoda();    E.protected void methoda(double d1){}   </p>
		<p>
				<br />108. Given:   </p>
		<p>1. int index=1;   </p>
		<p>2. int[] foo=new int[3];   </p>
		<p>3. int bar=foo[index];   </p>
		<p>4 . int baz=bar+index;   </p>
		<p>What is the result?   </p>
		<p>A.baz has a value of 0.   </p>
		<p>B.baz has a value of 1.   </p>
		<p>C.baz has a value of 2.   </p>
		<p>D.An exception is thrown.   </p>
		<p>E.The code will not compile. </p>
		<p>
				<br />109.Which three are equivalent to line 2?  </p>
		<p>interface foo{   </p>
		<p>int i=10;   </p>
		<p>}   </p>
		<p>A.static i=10;    B.final i=10;    C.public i=10;   D.protected i=10;    E.private i=10;   </p>
		<p>
				<br />110. What is the result?   </p>
		<p>public class A{   </p>
		<p>int getnumber(int a){   </p>
		<p>return a+1;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>public class B extends A{   </p>
		<p>int getnumber(int a){   </p>
		<p>return a+2;   </p>
		<p>}   </p>
		<p>public static void main(String args[]){   </p>
		<p>A b=new B();   </p>
		<p>System.out.println(b.getnumber(2));   </p>
		<p>}   </p>
		<p>}   </p>
		<p>A.print 3   B.print 4    C.print 5   D.It will not compile   </p>
		<p>
				<br />111. what is the result?   </p>
		<p>public class Test{   </p>
		<p>public static void main(String args[]){   </p>
		<p>String s=new String( ”true” );   </p>
		<p>Boolean b=new Boolean(true);   </p>
		<p>If(s.equals(b))   </p>
		<p>{ System.out.println(“hello” );}   </p>
		<p>}   </p>
		<p>}   </p>
		<p>A.print “hello”   B.compile error at line 6    C.compile succeed but print nothing   </p>
		<p>D.compile succeed but throw exception at runtime </p>
		<p>
				<br />112.What is the result?   </p>
		<p>public class Test{   </p>
		<p>static String s= ”Hello” ;   </p>
		<p>public static void main(String args[]){   </p>
		<p>Test t=new Test();   </p>
		<p>t.methodA(s);   </p>
		<p>System.out.println(s);   </p>
		<p>}   </p>
		<p>void methodA(String s){   </p>
		<p>s+=”World” ;   </p>
		<p>}   </p>
		<p>}   </p>
		<p>A.print “Hello”   B.print “World”   C.print “Hello World”   D.It does not compile </p>
<img src ="http://www.blogjava.net/bily/aggbug/81580.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 18:12 <a href="http://www.blogjava.net/bily/articles/81580.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java笔试题集（二）</title><link>http://www.blogjava.net/bily/articles/81499.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 04:30:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81499.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81499.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81499.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81499.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81499.html</trackback:ping><description><![CDATA[<p>[编程题] </p>
<p>1．现在输入n个数字，以逗号，分开；然后可选择升或者降序排序； 按提交键就在另一页面显示按什么 排序，结果为， ，提供reset </p>
<p>答案（1） public static String[] splitStringByComma(String source){ </p>
<p>if(source==null||source.trim().equals("")) </p>
<p>return null; </p>
<p>StringTokenizer commaToker = new StringTokenizer(source,","); </p>
<p>String[] result = new String[commaToker.countTokens()]; </p>
<p>int i=0; </p>
<p>while(commaToker.hasMoreTokens()){ </p>
<p>result[i] = commaToker.nextToken(); </p>
<p>i++; </p>
<p>} </p>
<p>return result; </p>
<p>} </p>
<p>循环遍历String数组 </p>
<p>Integer.parseInt(String s)变成int类型 </p>
<p>组成int数组 </p>
<p>Arrays.sort(int[] a), </p>
<p>a数组升序 </p>
<p>降序可以从尾部开始输出 </p>
<p>2．金额转换，阿拉伯数字的金额转换成中国传统的形式如： </p>
<p>（￥1011）－&gt;（一千零一拾一元整）输出。 </p>
<p>3、继承时候类的执行顺序问题,一般都是选择题,问你将会打印出什么? </p>
<p>答:父类： </p>
<p>package test; </p>
<p>public class FatherClass { </p>
<p>public FatherClass() { </p>
<p>System.out.println("FatherClass Create"); </p>
<p>} </p>
<p>} </p>
<p>子类: </p>
<p>package test; </p>
<p>import test.FatherClass; </p>
<p>public class ChildClass extends FatherClass { </p>
<p>public ChildClass() { </p>
<p>System.out.println("ChildClass Create"); </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>FatherClass fc = new FatherClass(); </p>
<p>ChildClass cc = new ChildClass(); </p>
<p>} </p>
<p>} </p>
<p>输出结果： </p>
<p>C:&gt;java test.ChildClass </p>
<p>FatherClass Create </p>
<p>FatherClass Create </p>
<p>ChildClass Create </p>
<p>4、内部类的实现方式? </p>
<p>答：示例代码如下： </p>
<p>package test; </p>
<p>public class OuterClass { </p>
<p>private class InterClass { </p>
<p>public InterClass() { </p>
<p>System.out.println("InterClass Create"); </p>
<p>} </p>
<p>} </p>
<p>public OuterClass() { </p>
<p>InterClass ic = new InterClass(); </p>
<p>System.out.println("OuterClass Create"); </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>OuterClass oc = new OuterClass(); </p>
<p>} </p>
<p>} </p>
<p>输出结果: </p>
<p>C:&gt;java test/OuterClass </p>
<p>InterClass Create </p>
<p>OuterClass Create </p>
<p>再一个例题： </p>
<p>public class OuterClass { </p>
<p>private double d1 = 1.0; </p>
<p>//insert code here </p>
<p>} </p>
<p>You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.) </p>
<p>A. class InnerOne{ </p>
<p>public static double methoda() {return d1;} </p>
<p>} </p>
<p>B. public class InnerOne{ </p>
<p>static double methoda() {return d1;} </p>
<p>} </p>
<p>C. private class InnerOne{ </p>
<p>double methoda() {return d1;} </p>
<p>} </p>
<p>D. static class InnerOne{ </p>
<p>protected double methoda() {return d1;} </p>
<p>} </p>
<p>E. abstract class InnerOne{ </p>
<p>public abstract double methoda(); </p>
<p>} </p>
<p>说明如下： </p>
<p>一.静态内部类可以有静态成员，而非静态内部类则不能有静态成员。 故 A、B 错 </p>
<p>二.静态内部类的非静态成员可以访问外部类的静态变量，而不可访问外部类的非静态变量；return d1 出错。 </p>
<p>故 D 错 </p>
<p>三.非静态内部类的非静态成员可以访问外部类的非静态变量。 故 C 正确 </p>
<p>四.答案为C、E </p>
<p>5、Java 的通信编程，编程题(或问答)，用JAVA SOCKET编程，读服务器几个字符，再写入本地显示？ </p>
<p>答:Server端程序: </p>
<p>package test; </p>
<p>import java.net.*; </p>
<p>import java.io.*; </p>
<p>public class Server { </p>
<p>private ServerSocket ss; </p>
<p>private Socket socket; </p>
<p>private BufferedReader in; </p>
<p>private PrintWriter out; </p>
<p>public Server() { </p>
<p>try { </p>
<p>ss=new ServerSocket(10000); </p>
<p>while(true) { </p>
<p>socket = ss.accept(); </p>
<p>String RemoteIP = socket.getInetAddress().getHostAddress(); </p>
<p>String RemotePort = ":"+socket.getLocalPort(); </p>
<p>System.out.println("A client come in!IP:"+RemoteIP+RemotePort); </p>
<p>in = new BufferedReader(new </p>
<p>InputStreamReader(socket.getInputStream())); </p>
<p>String line = in.readLine(); </p>
<p>System.out.println("Cleint send is :" + line); </p>
<p>out = new PrintWriter(socket.getOutputStream(),true); </p>
<p>out.println("Your Message Received!"); </p>
<p>out.close(); </p>
<p>in.close(); </p>
<p>socket.close(); </p>
<p>} </p>
<p>}catch (IOException e) { </p>
<p>out.println("wrong"); </p>
<p>} </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>new Server(); </p>
<p>} </p>
<p>}; </p>
<p>Client端程序: </p>
<p>package test; </p>
<p>import java.io.*; </p>
<p>import java.net.*; <br />
&nbsp;<br />
public class Client { </p>
<p>Socket socket; </p>
<p>BufferedReader in; </p>
<p>PrintWriter out; </p>
<p>public Client() { </p>
<p>try { </p>
<p>System.out.println("Try to Connect to 127.0.0.1:10000"); </p>
<p>socket = new Socket("127.0.0.1",10000); </p>
<p>System.out.println("The Server Connected!"); </p>
<p>System.out.println("Please enter some Character:"); </p>
<p>BufferedReader line = new BufferedReader(new </p>
<p>InputStreamReader(System.in)); </p>
<p>out = new PrintWriter(socket.getOutputStream(),true); </p>
<p>out.println(line.readLine()); </p>
<p>in = new BufferedReader(new InputStreamReader(socket.getInputStream())); </p>
<p>System.out.println(in.readLine()); </p>
<p>out.close(); </p>
<p>in.close(); </p>
<p>socket.close(); </p>
<p>}catch(IOException e) { </p>
<p>out.println("Wrong"); </p>
<p>} </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>new Client(); </p>
<p>} </p>
<p>}; </p>
<p>6、用JAVA实现一种排序，JAVA类实现序列化的方法(二种)？ 如在COLLECTION框架中，实现比较要实现什么样的接口？ </p>
<p>答:用插入法进行排序代码如下 </p>
<p>package test; </p>
<p>import java.util.*; </p>
<p>class InsertSort { </p>
<p>ArrayList al; </p>
<p>public InsertSort(int num,int mod) { </p>
<p>al = new ArrayList(num); </p>
<p>Random rand = new Random(); </p>
<p>System.out.println("The ArrayList Sort Before:"); </p>
<p>for (int i=0;i&lt;num ;i++ ) { </p>
<p>al.add(new Integer(Math.abs(rand.nextInt()) % mod + 1)); </p>
<p>System.out.println("al["+i+"]="+al.get(i)); </p>
<p>} </p>
<p>} </p>
<p>public void SortIt() { </p>
<p>Integer tempInt; </p>
<p>int MaxSize=1; </p>
<p>for(int i=1;i&lt;al.size();i++) { </p>
<p>tempInt = (Integer)al.remove(i); </p>
<p>if(tempInt.intValue()&gt;=((Integer)al.get(MaxSize-1)).intValue()) { </p>
<p>al.add(MaxSize,tempInt); </p>
<p>MaxSize++; </p>
<p>System.out.println(al.toString()); </p>
<p>} else { </p>
<p>for (int j=0;j&lt;MaxSize ;j++ ) { </p>
<p>if (((Integer)al.get(j)).intValue()&gt;=tempInt.intValue()) { </p>
<p>al.add(j,tempInt); </p>
<p>MaxSize++; </p>
<p>System.out.println(al.toString()); </p>
<p>break; </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>System.out.println("The ArrayList Sort After:"); </p>
<p>for(int i=0;i&lt;al.size();i++) { </p>
<p>System.out.println("al["+i+"]="+al.get(i)); </p>
<p>} </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>InsertSort is = new InsertSort(10,100); </p>
<p>is.SortIt(); </p>
<p>} </p>
<p>} </p>
<p>　　JAVA类实现序例化的方法是实现java.io.Serializable接口 </p>
<p>　　Collection框架中实现比较要实现Comparable 接口和 Comparator 接口 </p>
<p>7、编程：编写一个截取字符串的函数，输入为一个字符串和字节数，输出为按字节截取的字符串。 但是要保证汉字不被截半个，如&#8220;我ABC&#8221;4，应该截为&#8220;我AB&#8221;，输入&#8220;我ABC汉DEF&#8221;，6，应该输出为&#8220;我ABC&#8221;而不是&#8220;我ABC+汉的半个&#8221;。 </p>
<p>　　答：代码如下： </p>
<p>package test; </p>
<p>class SplitString { </p>
<p>String SplitStr; </p>
<p>int SplitByte; </p>
<p>public SplitString(String str,int bytes) { </p>
<p>SplitStr=str; </p>
<p>SplitByte=bytes; </p>
<p>System.out.println("The String is:&#8242;"+SplitStr+"&#8242;;SplitBytes="+SplitByte); </p>
<p>} </p>
<p>public void SplitIt() { </p>
<p>int loopCount; </p>
<p>loopCount=(SplitStr.length()%SplitByte==0)?(SplitStr.length()/SplitByte):(SplitStr.length</p>
<p>()/Split Byte+1); </p>
<p>System.out.println("Will Split into "+loopCount); </p>
<p>for (int i=1;i&lt;=loopCount ;i++ ) { </p>
<p>if (i==loopCount){ </p>
<p>System.out.println(SplitStr.substring((i-1)*SplitByte,SplitStr.length())); </p>
<p>} else { </p>
<p>System.out.println(SplitStr.substring((i-1)*SplitByte,(i*SplitByte))); </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>SplitString ss = new SplitString("test中dd文dsaf中男大3443n中国43中国人 0ewldfls=103",4); </p>
<p>ss.SplitIt(); </p>
<p>} </p>
<p>} </p>
<p>8、JAVA多线程编程。 用JAVA写一个多线程程序，如写四个线程，二个加1，二个对一个变量减一，输出。 </p>
<p>　　希望大家补上，谢谢 </p>
<p>9、STRING与STRINGBUFFER的区别。 </p>
<p>　　答：STRING的长度是不可变的，STRINGBUFFER的长度是可变的。如果你对字符串中的内容经常进行操作，特别是内容要修改时，那么使用StringBuffer，如果最后需要String，那么使用StringBuffer的toString()方法 </p>
<p>[Jsp方面]</p>
<p>1、jsp有哪些内置对象?作用分别是什么? </p>
<p>　　答:JSP共有以下9种基本内置组件（可与ASP的6种内部组件相对应）： </p>
<p>　　request 用户端请求，此请求会包含来自GET/POST请求的参数 </p>
<p>　　response 网页传回用户端的回应 </p>
<p>　　pageContext 网页的属性是在这里管理 </p>
<p>　　session 与请求有关的会话期 </p>
<p>　　application servlet 正在执行的内容 </p>
<p>　　out 用来传送回应的输出 </p>
<p>　　config servlet的构架部件 </p>
<p>　　page JSP网页本身 </p>
<p>　　exception 针对错误网页，未捕捉的例外 </p>
<p>2、jsp有哪些动作?作用分别是什么? </p>
<p>　　答:JSP共有以下6种基本动作 </p>
<p>　　jsp:include：在页面被请求的时候引入一个文件。 </p>
<p>　　jsp:useBean：寻找或者实例化一个JavaBean。 </p>
<p>　　jsp:setProperty：设置JavaBean的属性。 </p>
<p>　　jsp:getProperty：输出某个JavaBean的属性。 </p>
<p>　　jsp:forward：把请求转到一个新的页面。 </p>
<p>　　jsp:plugin：根据浏览器类型为Java插件生成OBJECT或EMBED标记 </p>
<p>3、JSP中动态INCLUDE与静态INCLUDE的区别？ </p>
<p>　　答：动态INCLUDE用jsp:include动作实现 </p>
<p>　　&lt;jsp:include page="included.jsp" flush="true" /&gt;它总是会检查所含文件中的变化，适合用于包含动态页面，并且可以带参数静态INCLUDE用include伪码实现,定不会检查所含文件的变化，适用于包含静态页面 </p>
<p>　　&lt;%@ include file="included.htm" %&gt; </p>
<p>4、两种跳转方式分别是什么?有什么区别? </p>
<p>　　答：有两种，分别为： </p>
<p>　　&lt;jsp:include page="included.jsp" flush="true"&gt; </p>
<p>　　&lt;jsp:forward page= "nextpage.jsp"/&gt; </p>
<p>　　前者页面不会转向include所指的页面，只是显示该页的结果，主页面还是原来的页面。执行完后还会回来，相当于函数调用。并且可以带参数.后者完全转向新页面，不会再回来。相当于go to 语句。 </p>
<p>[Servlet方面] </p>
<p>1、说一说Servlet的生命周期? </p>
<p>　　答:servlet有良好的生存期的定义，包括加载和实例化、初始化、处理请求以及服务结束。这个生存期由javax.servlet.Servlet接口的init,service和destroy方法表达。 </p>
<p>2、Servlet版本间(忘了问的是哪两个版本了)的不同? </p>
<p>　　希望大家补上，谢谢 </p>
<p>3、JAVA SERVLET API中forward() 与redirect()的区别？ </p>
<p>　　答:前者仅是容器中控制权的转向，在客户端浏览器地址栏中不会显示出转向后的地址；后者则是完全的跳转，浏览器将会得到跳转的地址，并重新发送请求链接。这样，从浏览器的地址栏中可以看到跳转后的链接地址。所以，前者更加高效，在前者可以满足需要时，尽量使用forward()方法，并且，这样也有助于隐藏实际的链接。在有些情况下，比如，需要跳转到一个其它服务器上的资源，则必须使用sendRedirect()方法。 </p>
<p>4、Servlet的基本架构 </p>
<p>public class ServletName extends HttpServlet { </p>
<p>public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { </p>
<p>} </p>
<p>public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { </p>
<p>} </p>
<p>} </p>
<p>[Jdbc、Jdo方面] </p>
<p>1、可能会让你写一段Jdbc连Oracle的程序,并实现数据查询. </p>
<p>　　答:程序如下： </p>
<p>package hello.ant; </p>
<p>import java.sql.*; </p>
<p>public class jdbc { </p>
<p>String dbUrl="jdbc:oracle:thin:@127.0.0.1:1521:orcl"; </p>
<p>String theUser="admin"; </p>
<p>String thePw="manager"; </p>
<p>Connection c=null; </p>
<p>Statement conn; </p>
<p>ResultSet rs=null; </p>
<p>public jdbc() { </p>
<p>try{ </p>
<p>Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); </p>
<p>c = DriverManager.getConnection(dbUrl,theUser,thePw); </p>
<p>conn=c.createStatement(); </p>
<p>}catch(Exception e){ </p>
<p>e.printStackTrace(); </p>
<p>} </p>
<p>} </p>
<p>public boolean executeUpdate(String sql) { </p>
<p>try { </p>
<p>conn.executeUpdate(sql); </p>
<p>return true; </p>
<p>} </p>
<p>catch (SQLException e) { </p>
<p>e.printStackTrace(); </p>
<p>return false; </p>
<p>} </p>
<p>} </p>
<p>public ResultSet executeQuery(String sql) { </p>
<p>rs=null; </p>
<p>try { </p>
<p>rs=conn.executeQuery(sql); </p>
<p>} </p>
<p>catch (SQLException e) { </p>
<p>e.printStackTrace(); </p>
<p>} </p>
<p>return rs; </p>
<p>} </p>
<p>public void close() { </p>
<p>try { </p>
<p>conn.close(); </p>
<p>c.close(); </p>
<p>} </p>
<p>catch (Exception e) { </p>
<p>e.printStackTrace(); </p>
<p>} </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>ResultSet rs; </p>
<p>jdbc conn = new jdbc(); </p>
<p>rs=conn.executeQuery("select * from test"); </p>
<p>try{ </p>
<p>while (rs.next()) { </p>
<p>System.out.println(rs.getString("id")); </p>
<p>System.out.println(rs.getString("name")); </p>
<p>} </p>
<p>}catch(Exception e) { </p>
<p>e.printStackTrace(); </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>2、Class.forName的作用?为什么要用? </p>
<p>　　答：调用该访问返回一个以字符串指定类名的类的对象。 </p>
<p>3、Jdo是什么? </p>
<p>　　答:JDO是Java对象持久化的新的规范，为java data object的简称,也是一个用于存取某种数据仓库中的对象的标准化API。JDO提供了透明的对象存储，因此对开发人员来说，存储数据对象完全不需要额外的代码（如JDBC API的使用）。这些繁琐的例行工作已经转移到JDO产品提供商身上，使开发人员解脱出来，从而集中时间和精力在业务逻辑上。另外，JDO很灵活，因为它可以在任何数据底层上运行。JDBC只是面向关系数据库（RDBMS)JDO更通用，提供到任何数据底层的存储功能，比如关系数据库、文件、XML以及对象数据库（ODBMS）等等，使得应用可移植性更强。 </p>
<p>4、在ORACLE大数据量下的分页解决方法。一般用截取ID方法，还有是三层嵌套方法。 </p>
<p>　　答:一种分页方法 </p>
<p>&lt;% </p>
<p>int i=1; </p>
<p>int numPages=14; </p>
<p>String pages = request.getParameter("page") ; </p>
<p>int currentPage = 1; </p>
<p>currentPage=(pages==null)?(1):{Integer.parseInt(pages)} </p>
<p>sql = "select count(*) from tables"; </p>
<p>ResultSet rs = DBLink.executeQuery(sql) ; </p>
<p>while(rs.next()) i = rs.getInt(1) ; </p>
<p>int intPageCount=1; </p>
<p>intPageCount=(i%numPages==0)?(i/numPages):(i/numPages+1); </p>
<p>int nextPage ; </p>
<p>int upPage; </p>
<p>nextPage = currentPage+1; </p>
<p>if (nextPage&gt;=intPageCount) nextPage=intPageCount; </p>
<p>upPage = currentPage-1; </p>
<p>if (upPage&lt;=1) upPage=1; </p>
<p>rs.close(); </p>
<p>sql="select * from tables"; </p>
<p>rs=DBLink.executeQuery(sql); </p>
<p>i=0; </p>
<p>while((i&lt;numPages*(currentPage-1))&amp;&amp;rs.next()){i++;} </p>
<p>%&gt; </p>
<p>//输出内容 </p>
<p>//输出翻页连接 </p>
<p>合计:&lt;%=currentPage%&gt;/&lt;%=intPageCount%&gt;&lt;a href="List.jsp?page=1"&gt;第一页&lt;/a&gt;&lt;a </p>
<p>href="List.jsp?page=&lt;%=upPage%&gt;"&gt;上一页&lt;/a&gt; </p>
<p>&lt;% </p>
<p>for(int j=1;j&lt;=intPageCount;j++){ </p>
<p>if(currentPage!=j){ </p>
<p>%&gt; </p>
<p>&lt;a href="list.jsp?page=&lt;%=j%&gt;"&gt;[&lt;%=j%&gt;]&lt;/a&gt; </p>
<p>&lt;% </p>
<p>}else{ </p>
<p>out.println(j); </p>
<p>} </p>
<p>} </p>
<p>%&gt; </p>
<p>&lt;a href="List.jsp?page=&lt;%=nextPage%&gt;"&gt;下一页&lt;/a&gt;&lt;a href="List.jsp?page=&lt;%=intPageCount%&gt;"&gt;最</p>
<p>后页 </p>
<p>&lt;/a&gt; </p>
<p>[Xml方面] </p>
<p>1、xml有哪些解析技术?区别是什么? </p>
<p>　　答:有DOM,SAX,STAX等 </p>
<p>　　DOM:处理大型文件时其性能下降的非常厉害。这个问题是由DOM的树结构所造成的，这种结构占用的内存较多，而且DOM必须在解析文件之前把整个文档装入内存,适合对XML的随机访问</p>
<p>　　SAX:不现于DOM,SAX是事件驱动型的XML解析方式。它顺序读取XML文件，不需要一次全部装载整个文件。当遇到像文件开头，文档结束，或者标签开头与标签结束时，它会触发一个事件，用户通过在其回调事件中写入处理代码来处理XML文件，适合对XML的顺序访问 </p>
<p>　　STAX:Streaming API for XML (StAX) </p>
<p>2、你在项目中用到了xml技术的哪些方面?如何实现的? </p>
<p>　　答:用到了数据存贮，信息配置两方面。在做数据交换平台时，将不能数据源的数据组装成XML文件，然后将XML文件压缩打包加密后通过网络传送给接收者，接收解密与解压缩后再同XML文件中还原相关信息进行处理。在做软件配置时，利用XML可以很方便的进行，软件的各种配置参数都存贮在XML文件中。 </p>
<p>3、用jdom解析xml文件时如何解决中文问题?如何解析? </p>
<p>　　答:看如下代码,用编码方式加以解决 </p>
<p>package test; </p>
<p>import java.io.*; </p>
<p>public class DOMTest { </p>
<p>private String inFile = "c:\people.xml"; </p>
<p>private String outFile = "c:\people.xml"; </p>
<p>public static void main(String args[]) { </p>
<p>new DOMTest(); </p>
<p>} </p>
<p>public DOMTest() { </p>
<p>try { </p>
<p>javax.xml.parsers.DocumentBuilder builder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); </p>
<p>org.w3c.dom.Document doc = builder.newDocument(); </p>
<p>org.w3c.dom.Element root = doc.createElement("老师"); </p>
<p>org.w3c.dom.Element wang = doc.createElement("王"); </p>
<p>org.w3c.dom.Element liu = doc.createElement("刘"); </p>
<p>wang.appendChild(doc.createTextNode("我是王老师")); </p>
<p>root.appendChild(wang); </p>
<p>doc.appendChild(root); </p>
<p>javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer(); </p>
<p>transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, "gb2312"); </p>
<p>transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes"); </p>
<p>transformer.transform(new javax.xml.transform.dom.DOMSource(doc), </p>
<p>new </p>
<p>javax.xml.transform.stream.StreamResult(outFile)); </p>
<p>} </p>
<p>catch (Exception e) { </p>
<p>System.out.println (e.getMessage()); </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>4、编程用JAVA解析XML的方式. </p>
<p>　　答:用SAX方式解析XML，XML文件如下： </p>
<p>&lt;?xml version="1.0" encoding="gb2312"?&gt; </p>
<p>&lt;person&gt; </p>
<p>&lt;name&gt;王小明&lt;/name&gt; </p>
<p>&lt;college&gt;信息学院&lt;/college&gt; </p>
<p>&lt;telephone&gt;6258113&lt;/telephone&gt; </p>
<p>&lt;notes&gt;男,1955年生,博士，95年调入海南大学&lt;/notes&gt; </p>
<p>&lt;/person&gt; </p>
<p>事件回调类SAXHandler.java </p>
<p>import java.io.*; </p>
<p>import java.util.Hashtable; </p>
<p>import org.xml.sax.*; </p>
<p>public class SAXHandler extends HandlerBase { </p>
<p>private Hashtable table = new Hashtable(); </p>
<p>private String currentElement = null; </p>
<p>private String currentValue = null; </p>
<p>public void setTable(Hashtable table) { </p>
<p>this.table = table; </p>
<p>} </p>
<p>public Hashtable getTable() { </p>
<p>return table; </p>
<p>} </p>
<p>public void startElement(String tag, AttributeList attrs) throws SAXException { </p>
<p>currentElement = tag; </p>
<p>} </p>
<p>public void characters(char[] ch, int start, int length) throws SAXException { </p>
<p>currentValue = new String(ch, start, length); </p>
<p>} </p>
<p>public void endElement(String name) throws SAXException { </p>
<p>if (currentElement.equals(name)) </p>
<p>table.put(currentElement, currentValue); </p>
<p>} </p>
<p>} </p>
<p>JSP内容显示源码,SaxXml.jsp: </p>
<p>&lt;HTML&gt; </p>
<p>&lt;HEAD&gt; </p>
<p>&lt;TITLE&gt;剖析XML文件people.xml&lt;/TITLE&gt; </p>
<p>&lt;/HEAD&gt; </p>
<p>&lt;BODY&gt; </p>
<p>&lt;%@ page errorPage="ErrPage.jsp" </p>
<p>contentType="text/html;charset=GB2312" %&gt; </p>
<p>&lt;%@ page import="java.io.*" %&gt; </p>
<p>&lt;%@ page import="java.util.Hashtable" %&gt; </p>
<p>&lt;%@ page import="org.w3c.dom.*" %&gt; </p>
<p>&lt;%@ page import="org.xml.sax.*" %&gt; </p>
<p>&lt;%@ page import="javax.xml.parsers.SAXParserFactory" %&gt; </p>
<p>&lt;%@ page import="javax.xml.parsers.SAXParser" %&gt; </p>
<p>&lt;%@ page import="SAXHandler" %&gt; </p>
<p>&lt;% </p>
<p>File file = new File("c:\people.xml"); </p>
<p>FileReader reader = new FileReader(file); </p>
<p>Parser parser; </p>
<p>SAXParserFactory spf = SAXParserFactory.newInstance(); </p>
<p>SAXParser sp = spf.newSAXParser(); </p>
<p>SAXHandler handler = new SAXHandler(); </p>
<p>sp.parse(new InputSource(reader), handler); </p>
<p>Hashtable hashTable = handler.getTable(); </p>
<p>out.println("&lt;TABLE BORDER=2&gt;&lt;CAPTION&gt;教师信息表&lt;/CAPTION&gt;"); </p>
<p>out.println("&lt;TR&gt;&lt;TD&gt;姓名&lt;/TD&gt;" + "&lt;TD&gt;" + </p>
<p>(String)hashTable.get(new String("name")) + "&lt;/TD&gt;&lt;/TR&gt;"); </p>
<p>out.println("&lt;TR&gt;&lt;TD&gt;学院&lt;/TD&gt;" + "&lt;TD&gt;" + </p>
<p>(String)hashTable.get(new String("college"))+"&lt;/TD&gt;&lt;/TR&gt;"); </p>
<p>out.println("&lt;TR&gt;&lt;TD&gt;电话&lt;/TD&gt;" + "&lt;TD&gt;" + </p>
<p>(String)hashTable.get(new String("telephone")) + "&lt;/TD&gt;&lt;/TR&gt;"); </p>
<p>out.println("&lt;TR&gt;&lt;TD&gt;备注&lt;/TD&gt;" + "&lt;TD&gt;" + </p>
<p>(String)hashTable.get(new String("notes")) + "&lt;/TD&gt;&lt;/TR&gt;"); </p>
<p>out.println("&lt;/TABLE&gt;"); </p>
<p>%&gt; </p>
<p>&lt;/BODY&gt; </p>
<p>&lt;/HTML&gt; </p>
<p>[EJB方面] </p>
<p>1、EJB2.0有哪些内容?分别用在什么场合? EJB2.0和EJB1.1的区别? </p>
<p>　　答：规范内容包括Bean提供者，应用程序装配者，EJB容器，EJB配置工具，EJB服务提供者，系统管理员。这里面，EJB容器是EJB之所以能够运行的核心。EJB容器管理着EJB的创建，撤消，激活，去活，与数据库的连接等等重要的核心工作。JSP,Servlet,EJB,JNDI,JDBC,JMS..... </p>
<p>2、EJB与JAVA BEAN的区别？ </p>
<p>　　答:Java Bean 是可复用的组件，对Java Bean并没有严格的规范，理论上讲，任何一个Java类都可以是一个Bean。但通常情况下，由于Java Bean是被容器所创建（如Tomcat)的，所以Java Bean应具有一个无参的构造器，另外，通常Java Bean还要实现Serializable接口用于实现Bean的持久性。Java Bean实际上相当于微软COM模型中的本地进程内COM组件，它是不能被跨进程访问的。Enterprise Java Bean 相当于DCOM，即分布式组件。它是基于Java的远程方法调用（RMI）技术的，所以EJB可以被远程访问（跨进程、跨计算机）。但EJB必须被布署在诸如Webspere、WebLogic这样的容器中，EJB客户从不直接访问真正的EJB组件，而是通过其容器访问。EJB容器是EJB组件的代理，EJB组件由容器所创建和管理。客户通过容器来访问真正的EJB组件。 </p>
<p>3、EJB的基本架构 </p>
<p>　　答:一个EJB包括三个部分: </p>
<p>Remote Interface 接口的代码 </p>
<p>package Beans; </p>
<p>import javax.ejb.EJBObject; </p>
<p>import java.rmi.RemoteException; </p>
<p>public interface Add extends EJBObject </p>
<p>{ </p>
<p>//some method declare </p>
<p>} </p>
<p>Home Interface 接口的代码 </p>
<p>package Beans; </p>
<p>import java.rmi.RemoteException; </p>
<p>import jaax.ejb.CreateException; </p>
<p>import javax.ejb.EJBHome; </p>
<p>public interface AddHome extends EJBHome { </p>
<p>//some method declare </p>
<p>} </p>
<p>EJB类的代码 </p>
<p>package Beans; </p>
<p>import java.rmi.RemoteException; </p>
<p>import javax.ejb.SessionBean; </p>
<p>import javx.ejb.SessionContext; </p>
<p>public class AddBean Implements SessionBean { </p>
<p>//some method declare </p>
<p>} </p>
<p>[J2EE,MVC方面] </p>
<p>1、MVC的各个部分都有那些技术来实现?如何实现? </p>
<p>　　答:MVC是Model－View－Controller的简写。"Model" 代表的是应用的业务逻辑（通过JavaBean，EJB组件实现）， "View" 是应用的表示面（由JSP页面产生），"Controller" 是提供应用的处理过程控制（一般是一个Servlet），通过这种设计模型把应用逻辑，处理过程和显示逻辑分成不同的组件实现。这些组件可以进行交互和重用。 </p>
<p>2、应用服务器与WEB SERVER的区别？ </p>
<p>　　希望大家补上，谢谢 </p>
<p>3、J2EE是什么？ </p>
<p>　　答:Je22是Sun公司提出的多层(multi-diered),分布式(distributed),基于组件(component-base)的企业级应用模型(enterpriese application model).在这样的一个应用系统中，可按照功能划分为不同的组件，这些组件又可在不同计算机上，并且处于相应的层次(tier)中。所属层次包括客户层(clietn tier)组件,web层和组件,Business层和组件,企业信息系统(EIS)层。 </p>
<p>4、WEB SERVICE名词解释。JSWDL开发包的介绍。JAXP、JAXM的解释。SOAP、UDDI,WSDL解释。 </p>
<p>　　答：Web Service描述语言WSDL </p>
<p>　　SOAP即简单对象访问协议(Simple Object Access Protocol)，它是用于交换XML编码信息的轻量级协议。 </p>
<p>　　UDDI 的目的是为电子商务建立标准；UDDI是一套基于Web的、分布式的、为Web Service提供的、信息注册中心的实现标准规范，同时也包含一组使企业能将自身提供的Web Service注册，以使别的企业能够发现的访问协议的实现标准。 </p>
<p>5、BS与CS的联系与区别。 </p>
<p>　　希望大家补上，谢谢 </p>
<p>6、STRUTS的应用(如STRUTS架构) </p>
<p>　　答：Struts是采用Java Servlet/JavaServer Pages技术，开发Web应用程序的开放源码的framework。 采用Struts能开发出基于MVC(Model-View-Controller)设计模式的应用构架。 Struts有如下的主要功能： </p>
<p>　　一.包含一个controller servlet，能将用户的请求发送到相应的Action对象。 </p>
<p>　　二.JSP自由tag库，并且在controller servlet中提供关联支持，帮助开发员创建交互式表单应用。 </p>
<p>　　三.提供了一系列实用对象：XML处理、通过Java reflection APIs自动处理JavaBeans属性、国际化的提示和消息。 </p>
<p>[设计模式方面] </p>
<p>1、开发中都用到了那些设计模式?用在什么场合? </p>
<p>　　答：每个模式都描述了一个在我们的环境中不断出现的问题，然后描述了该问题的解决方案的核心。通过这种方式，你可以无数次地使用那些已有的解决方案，无需在重复相同的工作。主要用到了MVC的设计模式。用来开发JSP/Servlet或者J2EE的相关应用。简单工厂模式等。 </p>
<p>2、UML方面 </p>
<p>　　答：标准建模语言UML。用例图,静态图(包括类图、对象图和包图),行为图,交互图(顺序图,合作图),实现图 </p>
<p>JavaScript方面 </p>
<p>1、如何校验数字型? </p>
<p>var re=/^d{1,8}$|.d{1,2}$/; </p>
<p>var str=document.form1.all(i).value; </p>
<p>var r=str.match(re); </p>
<p>if (r==null) { </p>
<p>sign=-4; </p>
<p>break; </p>
<p>} </p>
<p>else{ </p>
<p>document.form1.all(i).value=parseFloat(str); </p>
<p>} </p>
<p>[CORBA方面] </p>
<p>1、CORBA是什么?用途是什么? </p>
<p>　　答：CORBA 标准是公共对象请求代理结构(Common Object Request Broker Architecture)，由对象管理组织 (Object Management Group，缩写为 OMG)标准化。它的组成是接口定义语言(IDL), 语言绑定(binding:也译为联编)和允许应用程序间互操作的协议。 其目的为： </p>
<p>　　用不同的程序设计语言书写 </p>
<p>　　在不同的进程中运行 </p>
<p>　　为不同的操作系统开发 </p>
<p>[LINUX方面] </p>
<p>1、LINUX下线程，GDI类的解释。 </p>
<p>　　答：LINUX实现的就是基于核心轻量级进程的"一对一"线程模型，一个线程实体对应一个核心轻量级进程，而线程之间的管理在核外函数库中实现。 </p>
<p>　　GDI类为图像设备编程接口类库。 </p>
<p>[JAVA华为面试题] </p>
<p>(JAVA方面) </p>
<p>1 面向对象的特征有哪些方面 </p>
<p>2 String是最基本的数据类型吗? </p>
<p>3 int 和 Integer 有什么区别 </p>
<p>4 String 和StringBuffer的区别 </p>
<p>5 运行时异常与一般异常有何异同？ </p>
<p>　　异常表示程序运行过程中可能出现的非正常状态，运行时异常表示虚拟机的通常操作中可能遇到的异常，是一种常见运行错误。java编译器要求方法必须声明抛出可能发生的非运行时异常，但是并不要求必须声明抛出未被捕获的运行时异常。 </p>
<p>6 说出一些常用的类，包,接口，请各举5个 </p>
<p>7 说出ArrayList,Vector, LinkedList的存储性能和特性 </p>
<p>　　ArrayList和Vector都是使用数组方式存储数据，此数组元素数大于实际存储的数据以便增加和插入元素，它们都允许直接按序号索引元素，但是插入元素要涉及数组元素移动等内存操作，所以索引数据快而插入数据慢，Vector由于使用了synchronized方法（线程安全），通常性能上较ArrayList差，而LinkedList使用双向链表实现存储，按序号索引数据需要进行前向或后向遍历，但是插入数据时只需要记录本项的前后项即可，所以插入速度较快。 </p>
<p>8 设计4个线程，其中两个线程每次对j增加1，另外两个线程对j每次减少1。写出程序。 </p>
<p>　　以下程序使用内部类实现线程，对j增减的时候没有考虑顺序问题。 </p>
<p>public class ThreadTest1{ </p>
<p>private int j; </p>
<p>public static void main(String args[]){ </p>
<p>ThreadTest1 tt=new ThreadTest1(); </p>
<p>Inc inc=tt.new Inc(); </p>
<p>Dec dec=tt.new Dec(); </p>
<p>for(int i=0;i&lt;2;i++){ </p>
<p>Thread t=new Thread(inc); </p>
<p>t.start(); </p>
<p>t=new Thread(dec); </p>
<p>t.start(); </p>
<p>} </p>
<p>} </p>
<p>private synchronized void inc(){ </p>
<p>j++; </p>
<p>System.out.println(Thread.currentThread().getName()+"-inc:"+j); </p>
<p>} </p>
<p>private synchronized void dec(){ </p>
<p>j--; </p>
<p>System.out.println(Thread.currentThread().getName()+"-dec:"+j); </p>
<p>} </p>
<p>&nbsp;</p>
<p>class Inc implements Runnable{ </p>
<p>public void run(){ </p>
<p>for(int i=0;i&lt;100;i++){ </p>
<p>inc(); </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>class Dec implements Runnable{ </p>
<p>public void run(){ </p>
<p>for(int i=0;i&lt;100;i++){ </p>
<p>dec(); </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>9． JSP的内置对象及方法。 </p>
<p>　　request request表示HttpServletRequest对象。它包含了有关浏览器请求的信息，并且提供了几个用于获取cookie, header, 和session数据的有用的方法。 </p>
<p>　　response response表示HttpServletResponse对象，并提供了几个用于设置送回 浏览器的响应的方法（如cookies,头信息等） </p>
<p>　　out out 对象是javax.jsp.JspWriter的一个实例，并提供了几个方法使你能用于向浏览器回送输出结果。 </p>
<p>　　pageContext pageContext表示一个javax.servlet.jsp.PageContext对象。它是用于方便存取各种范围的名字空间、servlet相关的对象的API，并且包装了通用的servlet相关功能的方法。 </p>
<p>　　session session表示一个请求的javax.servlet.http.HttpSession对象。Session可以存贮用户的状态信息 </p>
<p>　　application applicaton 表示一个javax.servle.ServletContext对象。这有助于查找有关servlet引擎和servlet环境的信息 </p>
<p>　　config config表示一个javax.servlet.ServletConfig对象。该对象用于存取servlet实例的初始化参数。 </p>
<p>　　page page表示从该页面产生的一个servlet实例 </p>
<p>10.用socket通讯写出客户端和服务器端的通讯，要求客户发送数据后能够回显相同的数据。 </p>
<p>　　参见课程中socket通讯例子。 </p>
<p>11说出Servlet的生命周期，并说出Servlet和CGI的区别。 </p>
<p>　　Servlet被服务器实例化后，容器运行其init方法，请求到达时运行其service方法，service方法自动派遣运行与请求对应的doXXX方法（doGet，doPost）等，当服务器决定将实例销毁的时候调用其destroy方法。 </p>
<p>&nbsp;&nbsp;&nbsp; 与cgi的区别在于servlet处于服务器进程中，它通过多线程方式运行其service方法，一个实例可以服务于多个请求，并且其实例一般不会销毁，而CGI对每个请求都产生新的进程，服务完成后就销毁，所以效率上低于servlet。 </p>
<p>12.EJB是基于哪些技术实现的?并说出SessionBean和EntityBean的区别，StatefulBean和StatelessBean的区别。 </p>
<p>13．EJB包括（SessionBean,EntityBean）说出他们的生命周期，及如何管理事务的？ </p>
<p>14．说出数据连接池的工作机制是什么? </p>
<p>15同步和异步有和异同，在什么情况下分别使用他们？举例说明。 </p>
<p>16应用服务器有那些？ </p>
<p>17你所知道的集合类都有哪些？主要方法？ </p>
<p>18给你一个:驱动程序A,数据源名称为B,用户名称为C,密码为D,数据库表为T，请用JDBC检索出表T的所有数据。 </p>
<p>19．说出在JSP页面里是怎么分页的? </p>
<p>　　页面需要保存以下参数： </p>
<p>　　总行数：根据sql语句得到总行数 </p>
<p>　　每页显示行数：设定值 </p>
<p>　　当前页数：请求参数 </p>
<p>　　页面根据当前页数和每页行数计算出当前页第一行行数，定位结果集到此行，对结果集取出每页显示行数的行即可。 </p>
<p>(数据库方面) </p>
<p>1. 存储过程和函数的区别 </p>
<p>　　存储过程是用户定义的一系列sql语句的集合，涉及特定表或其它对象的任务，用户可以调用存储过程，而函数通常是数据库已定义的方法，它接收参数并返回某种类型的值并且不涉及特定用户表。 </p>
<p>2. 事务是什么？ </p>
<p>　　事务是作为一个逻辑单元执行的一系列操作，一个逻辑工作单元必须有四个属性，称为 ACID（原子性、一致性、隔离性和持久性）属性，只有这样才能成为一个事务： </p>
<p>　　原子性 </p>
<p>　　事务必须是原子工作单元；对于其数据修改，要么全都执行，要么全都不执行。 </p>
<p>　　一致性 </p>
<p>　　事务在完成时，必须使所有的数据都保持一致状态。在相关数据库中，所有规则都必须应用于事务的修改，以保持所有数据的完整性。事务结束时，所有的内部数据结构（如 B 树索引或双向链表）都必须是正确的。 </p>
<p>　　隔离性 </p>
<p>　　由并发事务所作的修改必须与任何其它并发事务所作的修改隔离。事务查看数据时数据所处的状态，要么是另一并发事务修改它之前的状态，要么是另一事务修改它之后的状态，事务不会查看中间状态的数据。这称为可串行性，因为它能够重新装载起始数据，并且重播一系列事务，以使数据结束时的状态与原始事务执行的状态相同。 </p>
<p>　　持久性 </p>
<p>　　事务完成之后，它对于系统的影响是永久性的。该修改即使出现系统故障也将一直保持。 </p>
<p>3. 游标的作用？如何知道游标已经到了最后？ </p>
<p>　　游标用于定位结果集的行，通过判断全局变量@@FETCH_STATUS可以判断是否到了最后，通常此变量不等于0表示出错或到了最后。 </p>
<p>4. 触发器分为事前触发和事后触发，这两种触发有和区别。语句级触发和行级触发有何区别。 </p>
<p>　　事前触发器运行于触发事件发生之前，而事后触发器运行于触发事件发生之后。通常事前触发器可以获取事件之前和新的字段值。 </p>
<p>　　语句级触发器可以在语句执行前或后执行，而行级触发在触发器所影响的每一行触发一次。 </p>
<p>[中远面试题] </p>
<p>1、面向对象的三个基本特征 </p>
<p>2、方法重载和方法重写的概念和区别 </p>
<p>3、接口和内部类、抽象类的特性 </p>
<p>4、文件读写的基本类 </p>
<p>5、串行化的注意事项以及如何实现串行化 </p>
<p>6、线程的基本概念、线程的基本状态以及状态之间的关系 </p>
<p>7、线程的同步、如何实现线程的同步 </p>
<p>8、几种常用的数据结构及内部实现原理。 </p>
<p>9、Socket通信(TCP、UDP区别及Java实现方式) </p>
<p>10、Java的事件委托机制和垃圾回收机制 </p>
<p>11、JDBC调用数据库的基本步骤 </p>
<p>12、解析XML文件的几种方式和区别 </p>
<p>13、Java四种基本权限的定义 </p>
<p>14、Java的国际化 </p>
<p>二、JSP </p>
<p>1、至少要能说出7个隐含对象以及他们的区别 </p>
<p>2、forward 和redirect的区别 </p>
<p>3、JSP的常用指令 </p>
<p>三、servlet </p>
<p>1、什么情况下调用doGet()和doPost()？ </p>
<p>2、servlet的init()方法和service()方法的区别 </p>
<p>3、servlet的生命周期 </p>
<p>4、如何现实servlet的单线程模式 </p>
<p>5、servlet的配置 </p>
<p>6、四种会话跟踪技术 </p>
<p>四、EJB </p>
<p>1、EJB容器提供的服务 </p>
<p>　　主要提供声明周期管理、代码产生、持续性管理、安全、事务管理、锁和并发行管理等服务。 </p>
<p>2、EJB的角色和三个对象 </p>
<p>　　EJB角色主要包括Bean开发者 应用组装者 部署者 系统管理员 EJB容器提供者 EJB服务器提供者三个对象是Remote（Local）接口、Home（LocalHome）接口，Bean类 </p>
<p>2、EJB的几种类型 </p>
<p>　　会话（Session）Bean ，实体（Entity）Bean 消息驱动的（Message Driven）Bean </p>
<p>　　会话Bean又可分为有状态（Stateful）和无状态（Stateless）两种 </p>
<p>　　实体Bean可分为Bean管理的持续性（BMP）和容器管理的持续性（CMP）两种 </p>
<p>3、bean 实例的生命周期 </p>
<p>　　对于Stateless Session Bean、Entity Bean、Message Driven Bean一般存在缓冲池管理，而对于Entity Bean和Statefull Session Bean存在Cache管理，通常包含创建实例，设置上下文、创建EJB Object（create）、业务方法调用、remove等过程，对于存在缓冲池管理的Bean，在create之后实例并不从内存清除，而是采用缓冲池调度机制不断重用实例，而对于存在Cache管理的Bean则通过激活和去激活机制保持Bean的状态并限制内存中实例数量。 </p>
<p>4、激活机制 </p>
<p>　　以Statefull Session Bean 为例：其Cache大小决定了内存中可以同时存在的Bean实例的数量，根据MRU或NRU算法，实例在激活和去激活状态之间迁移，激活机制是当客户端调用某个EJB实例业务方法时，如果对应EJB Object发现自己没有绑定对应的Bean实例则从其去激活Bean存储中（通过序列化机制存储实例）回复（激活）此实例。状态变迁前会调用对应的ejbActive和ejbPassivate方法。 </p>
<p>5、remote接口和home接口主要作用 </p>
<p>　　remote接口定义了业务方法，用于EJB客户端调用业务方法 </p>
<p>　　home接口是EJB工厂用于创建和移除查找EJB实例 </p>
<p>6、客服端调用EJB对象的几个基本步骤 </p>
<p>　　(1)设置JNDI服务工厂以及JNDI服务地址系统属性 </p>
<p>　　(2)查找Home接口 </p>
<p>　　(3)从Home接口调用Create方法创建Remote接口 </p>
<p>　　(4)通过Remote接口调用其业务方法 </p>
<p>五、数据库 </p>
<p>1、存储过程的编写 </p>
<p>2、基本的SQL语句 </p>
<p>六、weblogic </p>
<p>1、 如何给weblogic指定大小的内存? </p>
<p>　　在启动Weblogic的脚本中（位于所在Domian对应服务器目录下的startServerName），增加set MEM_ARGS=-Xms32m -Xmx200m，可以调整最小内存为32M，最大200M </p>
<p>2、 如何设定的weblogic的热启动模式(开发模式)与产品发布模式? </p>
<p>　　可以在管理控制台中修改对应服务器的启动模式为开发或产品模式之一。或者修改服务的启动文件或者commenv文件，增加set PRODUCTION_MODE=true。 </p>
<p>3、 如何启动时不需输入用户名与密码? </p>
<p>　　修改服务启动文件，增加 WLS_USER和WLS_PW项。也可以在boot.properties文件中增加加密过的用户名和密码. </p>
<p>4、 在weblogic管理制台中对一个应用域(或者说是一个网站,Domain)进行jms及ejb或连接池等相关信息进行配置后,实际保存在什么文件中? </p>
<p>　　保存在此Domain的config.xml文件中，它是服务器的核心配置文件。 </p>
<p>5、 说说weblogic中一个Domain的缺省目录结构?比如要将一个简单的helloWorld.jsp放入何目录下,然的在浏览器上就可打入http://主机:端口号//helloword.jsp就可以看到运行结果了? 又比如这其中用到了一个自己写的javaBean该如何办? </p>
<p>　　Domain目录\服务器目录\applications，将应用目录放在此目录下将可以作为应用访问，如果是Web应用，应用目录需要满足Web应用目录要求，jsp文件可以直接放在应用目录中，Javabean需要放在应用目录的WEB-INF目录的classes目录中，设置服务器的缺省应用将可以实现在浏览器上无需输入应用名。 </p>
<p>6、 如何查看在weblogic中已经发布的EJB? </p>
<p>　　可以使用管理控制台，在它的Deployment中可以查看所有已发布的EJB </p>
<p>7、 如何在weblogic中进行ssl配置与客户端的认证配置或说说j2ee(标准)进行ssl的配置缺省安装中使用DemoIdentity.jks和DemoTrust.jks KeyStore实现SSL，需要配置服务器使用Enable SSL，配置其端口，在产品模式下需要从CA获取私有密钥和数字证书，创建identity和trust keystore，装载获得的密钥和数字证书。可以配置此SSL连接是单向还是双向的。 </p>
<p>8、 在weblogic中发布ejb需涉及到哪些配置文件 </p>
<p>　　不同类型的EJB涉及的配置文件不同，都涉及到的配置文件包括ejb-jar.xml,weblogic-ejb-jar.xmlCMP实体Bean一般还需要weblogic-cmp-rdbms-jar.xml </p>
<p>9、 EJB需直接实现它的业务接口或Home接口吗,请简述理由. </p>
<p>　　远程接口和Home接口不需要直接实现，他们的实现代码是由服务器产生的，程序运行中对应实现类会作为对应接口类型的实例被使用。 </p>
<p>10、说说在weblogic中开发消息Bean时的persistent与non-persisten的差别 </p>
<p>　　persistent方式的MDB可以保证消息传递的可靠性,也就是如果EJB容器出现问题而JMS服务器依然会将消息在此MDB可用的时候发送过来，而non－persistent方式的消息将被丢弃。 </p>
<p>11、说说你所熟悉或听说过的j2ee中的几种常用模式?及对设计模式的一些看法 </p>
<p>　　Session Facade Pattern：使用SessionBean访问EntityBean </p>
<p>　　Message Facade Pattern：实现异步调用 </p>
<p>　　EJB Command Pattern：使用Command JavaBeans取代SessionBean，实现轻量级访问 </p>
<p>　　Data Transfer Object Factory：通过DTO Factory简化EntityBean数据提供特性 </p>
<p>　　Generic Attribute Access：通过AttibuteAccess接口简化EntityBean数据提供特性 </p>
<p>　　Business Interface：通过远程（本地）接口和Bean类实现相同接口规范业务逻辑一致性EJB架构的设计好坏将直接影响系统的性能、可扩展性、可维护性、组件可重用性及开发效率。项目越复杂，项目队伍越庞大则越能体现良好设计的重要性。</p>
<img src ="http://www.blogjava.net/bily/aggbug/81499.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 12:30 <a href="http://www.blogjava.net/bily/articles/81499.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>微软的应试题</title><link>http://www.blogjava.net/bily/articles/81494.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 04:23:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81494.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81494.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81494.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81494.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81494.html</trackback:ping><description><![CDATA[
		<p>一．最基本题型（说明：此类题型比较简单） <br />1.烧一根不均匀的绳，从头烧到尾总共需要1个小时。现在有若干条材质相同的绳子，问如 <br />何用烧绳的方法来计时一个小时十五分钟呢？ <br />2.你有一桶果冻，其中有黄色、绿色、红色三种，闭上眼睛抓取同种颜色的两个。抓取多少 <br />个就可以确定你肯定有两个同一颜色的果冻？（5秒-1分钟） <br />3.如果你有无穷多的水，一个3公升的提捅，一个5公升的提捅，两只提捅形状上下都不均匀 <br />，问你如何才能准确称出4公升的水？（40秒-3分钟） <br />4.一个岔路口分别通向诚实国和说谎国。来了两个人，已知一个是诚实国的，另一个是说谎 <br />国的。诚实国永远说实话，说谎国永远说谎话。现在你要去说谎国，但不知道应该走哪条路 <br />，需要问这两个人。请问应该怎么问？（20秒-2分钟） <br />5.12个球一个天平，现知道只有一个和其它的重量不同，问怎样称才能用三次就找到那个球 <br />。13个呢？（注意此题并未说明那个球的重量是轻是重，所以需要仔细考虑）（5分钟-1小 <br />时） <br />6.在9个点上画10条直线，要求每条直线上至少有三个点？（3分钟-20分钟） <br />7.在一天的24小时之中，时钟的时针、分针和秒针完全重合在一起的时候有几次？都分别是 <br />什么时间？你怎样算出来的？ <br />二．没有答案型（说明：这些题显然不是考你智力。而考的是你的反应能力。这种题大多数 <br />没有答案，但是要看你的反应喽！） <br />1.为什么下水道的盖子是圆的？ <br />2.中国有多少辆汽车？ <br />3.将汽车钥匙插入车门，向哪个方向旋转就可以打开车锁？ <br />4.如果你要去掉中国的34个省（含自治区、直辖市和港澳特区及台湾省）中的任何一个，你 <br />会去掉哪一个，为什么？ <br />5.多少个加油站才能满足中国的所有汽车？ <br />6.想象你站在镜子前，请问，为什么镜子中的影象可以颠倒左右，却不能颠倒上下？ <br />7.为什么在任何旅馆里，你打开热水，热水都会瞬间倾泻而出？ <br />8.你怎样将Excel的用法解释给你的奶奶听？   <br />9.你怎样重新改进和设计一个ATM银行自动取款机？ <br />10.如果你不得不重新学习一种新的计算机语言，你打算怎样着手来开始？ <br />11.如果你的生涯规划中打算在5年内受到奖励，那获取该项奖励的动机是什么？观众是谁？ </p>
		<p>12.如果微软告诉你，我们打算投资五百万美元来启动你的投资计划，你将开始什么样商业 <br />计划？为什么？ <br />13.如果你能够将全世界的电脑厂商集合在一个办公室里，然后告诉他们将被强迫做一件事 <br />，那件事将是什么？   <br />三．难题（说明：这类题有一定难度，如果得不到答案，也不能说明什么。如果你想到了解 <br />题思路，那么答案马上就能出来。如果想不到思路，那么……就别想解出来了。） <br />1.你让工人为你工作7天，回报是一根金条，这个金条平分成相连的7段，你必须在每天结束 <br />的时候给他们一段金条。如果只允许你两次把金条弄断，你如何给你的工人付费？ <br />2.有一辆火车以每小时15公里的速度离开北京直奔广州，同时另一辆火车每小时20公里的速 <br />度从广州开往北京。如果有一只鸟，以30公里每小时的速度和两辆火车同时启动，从北京出 <br />发，碰到另一辆车后就向相反的方向返回去飞，就这样依次在两辆火车之间来回地飞，直到 <br />两辆火车相遇。请问，这只鸟共飞行了多长的距离？ <br />3.你有四个装药丸的罐子，每个药丸都有一定的重量，被污染的药丸是没被污染的药丸的重 <br />量+1。只称量一次，如何判断哪个罐子的药被污染了？ <br />4.门外三个开关分别对应室内三盏灯，线路良好，在门外控制开关时候不能看到室内灯的情 <br />况，现在只允许进门一次，确定开关和灯的对应关系？ <br />5.人民币为什么只有1、2、5、10的面值？ <br />6.你有两个罐子以及50个红色弹球和50个蓝色弹球，随机选出一个罐子， 随机选出一个弹 <br />球放入罐子，怎么给出红色弹球最大的选中机会？在你的计划里，得到红球的几率是多少？ <br />  <br />四．超难题（说明：如果你是第一次看到这种题，并且以前从来没有见过类似的题型，并且 <br />能够在半个小时之内做出答案。只能说明你的智力超常……） <br />第一题 . 五个海盗抢到?00颗宝石，每一颗都一样大小和价值连城。他们决定这么分： <br />  抽签决定自己的号码（1、2、3、4、5） <br />  首先，由1号提出分配方案，然后大家表决，当且仅当超过半数的人同意时，按照他的方 <br />案进行分配，否则将被扔进大海喂鲨鱼 <br />  如果1号死后，再由2号提出分配方案，然后剩下的4人进行表决，当且仅当超过半数的人 <br />同意时，按照他的方案进行分配，否则将被扔入大海喂鲨鱼 <br />  依此类推 <br />条件：每个海盗都是很聪明的人，都能很理智地做出判断，从而做出选择。 <br />问题：第一个海盗提出怎样的分配方案才能使自己的收益最大化？ <br />第二题 . 一道关于飞机加油的问题，已知： <br />  每个飞机只有一个油箱，   <br />  飞机之间可以相互加油（注意是相互，没有加油机）   <br />  一箱油可供一架飞机绕地球飞半圈，   <br />问题： <br />为使至少一架飞机绕地球一圈回到起飞时的飞机场，至少需要出动几架飞机？（所有飞机从 <br />同一机场起飞，而且必须安全返回机场，不允许中途降落，中间没有飞机场）   <br />五．主观题（说明：在以后的工作过程中，我们可定会犯这样那样的错误。既然错误已经酿 <br />成，损失在所难免，我们只能想办法把损失减少到最小。如果能巧妙地回答出这些问题，再 <br />发生错误的情况下。能让客户有最少的抱怨，公司有最少的损失。） <br />1.某手机厂家由于设计失误，有可能造成电池寿命比原来设计的寿命短一半（不是冲放电时 <br />间），解决方案就是免费更换电池或给50元购买该厂家新手机的折换券。请给所有已购买的 <br />用户写信告诉解决方案。 <br />2.一高层领导在参观某博物馆时，向博物馆馆员小王要了一块明代的城砖作为纪念，按国家 <br />规定，任何人不得将博物馆收藏品变为私有。博物馆馆长需要如何写信给这位领导，将城砖 <br />取回。 <br />3.营业员小姐由于工作失误，将2万元的笔记本电脑以1.2万元错卖给李先生，王小姐的经理 <br />怎么写信给李先生试图将钱要回来？ <br />六.算法题（说明：这些题就不是什么花样了，考的是你的基础知识怎么样。再聪明而没有 <br />实学的人都将会被这些题所淘汰。） <br />1.链表和数组的区别在哪里？ <br />2.编写实现链表排序的一种算法。说明为什么你会选择用这样的方法？ <br />3.编写实现数组排序的一种算法。说明为什么你会选择用这样的方法？ <br />4.请编写能直接实现strstr()函数功能的代码。 <br />5.编写反转字符串的程序，要求优化速度、优化空间。 <br />6.在链表里如何发现循环链接？ <br />7.给出洗牌的一个算法，并将洗好的牌存储在一个整形数组里。 <br />8.写一个函数，检查字符是否是整数，如果是，返回其整数值。（或者：怎样只用4行代码 <br />编写出一个从字符串到长整形的函数？） <br />9.给出一个函数来输出一个字符串的所有排列。 <br />10.请编写实现malloc()内存分配函数功能一样的代码。 <br />11.给出一个函数来复制两个字符串A和B。字符串A的后几个字节和字符串B的前几个字节重 <br />叠。 <br />12.怎样编写一个程序，把一个有序整数数组放到二叉树中？ <br />13.怎样从顶部开始逐层打印二叉树结点数据？请编程。 <br />14.怎样把一个链表掉个顺序（也就是反序，注意链表的边界条件并考虑空链表）？ <br />［解答与提示］ <br />一．最基本题型 <br />1.取3根绳子。先拿任2根，总共有4个绳头，同时点燃3个。当第一根绳子烧完（30分钟）同 <br />时点燃第4个绳头（也就是第二根绳子的剩下一个绳头）。当第二根绳子烧完（30分钟+15分 <br />钟），立刻点燃第三根绳子的两头。当第三根绳子烧完正好是1个小时15分钟（30分钟+15分 <br />钟+30分钟）。 <br />2.4个。 <br />3.略...... <br />4.如果参加过类似于奥林匹克数学班的，都应做过这些题。问他你的国家怎么走，他肯定指 <br />向的是诚实国。 <br />5.略...... <br />6.   <br />7.目前为止答案有三种：11、22、24。不知道哪个才是正确的！ <br />二．没有答案型 <br />1.圆井盖掉不下去 <br />2.一千万（我这么认为） <br />3.我会回答顺时针方向。 <br />4.北京。（原因是我生在北京长在北京，想让北京脱离是因为想去看看外面的世界，既然美 <br />国人问咱们这种政治问题，咱们也就回应一个政治玩笑罢了） <br />5.十万个（可以创造将近一百万的就业岗位呢） <br />6.答案是“This feature is by design.” 如果考官要求给出更加合理的解释，就对他说 <br />：“如果您对此问题有更多疑问，请与它的供应商（或者与它的发明人）联系”。 <br />7.如果不倾泻而出，这家旅馆将没有人去住。（所以这个问题最好去问旅馆的老板。） <br />8.告诉她这是最先进的东西，她不需要动手，我来帮她做就可以。 <br />9.我想斯皮尔伯格来回答这道题是在合适不过得了。 <br />10.我觉得回放飞网呆上半个月比较合适。 <br />11.这题我没有任何想法，因为没有工作经验，所以完全没听明白他问的是什么！ <br />12.做微软的OEM，这样能够更好的服务微软。 <br />13.把主机箱集成在一个液晶显示器中！ <br />三．难题 <br />1.切两刀，分为1/7、2/7、4/7三段。第一天给1/7；第二天给2/7，要回1/7；第三天给1/7 <br /> ；第四天给4/7 要回1/7+2/7；第五天给1/7；第六天给2/7，要会1/7；第七天给1/7 <br />2.[Johnson提供]北京到广州的铁路线全长2295千米，不管鸟怎么飞，它飞行的时间就是两 <br />列火车相遇的时间，两列火车相遇时间是（15t+20t）=2295，t近似等于65小时，65乘以鸟 <br />飞行的速度30，1950千米。总之答案就是30*两列火车相遇的时间。 <br />3.依次从四个罐子中取出1、2、3、4个药丸，结果不用说了吧！ <br />4.先开一个，开很长时间。然后关掉，再开另一个。出去看，亮着的那个不用说。剩下的两 <br />个不亮的，按照灯泡的温度来进行判断。 <br />5.至今不知道应如何解答。 <br />6.不清楚。可能是50%。 <br />四.超难题 <br />第一题：期待高手 <br />第二题：[johnson提供]前提是理想状态的油必须瞬间加满。我的答案是六架飞机。 <br /> <br />说明： <br />1、飞机1、飞机2等飞机n为飞机的个数 <br />2、把整个圆（飞行轨道）周等分为8份，分别定为O点（起飞点），依次为A、B、C、D、E、 <br />F、G <br />设想一下，按题目要求一架飞机要想不加油安全的飞并且安全返回，能飞行最远距离是一个 <br />圆周的1/4，既飞行度距离是OB；如果给另外一架飞机加油的话它只能飞行1/8的距离OA。这 <br />些前提的存在，再根据题意就可推出如下的飞行放案： <br />1、首先同时从O点起飞三架飞机，当他们飞到A点时，飞机1、飞机2将继续飞行，飞机三给 <br />飞机1、飞机2加油，各加1/4的油，这样飞机1和飞机2就满油了；飞机3用剩下的1/4（飞到 <br />A点已经用去了1/4的油）的油刚好能飞回起点。 <br />2、飞机1、飞机2继续飞行。飞到B点时，飞机1将继续飞行，飞机2给飞机1加油，加1/4的油 <br />，这样飞机1的油箱又会加满油；飞机2用剩下的2/4（飞到B点又用去了1/4的油再加上给飞 <br />机1加的1/4油）的油刚好飞回起点。 <br />3、飞机1继续飞行，因为满油，所以可以飞半圈飞到F点。 <br />4、当飞机1飞到D点的时刻，同时从O点反方向派出三架飞机，飞机4、飞机5、飞机6。这样 <br />能保证飞机1飞到F点时刚好有两架飞机到达F点。（飞机4、飞机5、飞机6是沿着OG的方向飞 <br />行） <br />5、当飞机4、飞机5、飞机6飞到G点时，飞机6同时给飞机4、飞机5加油。飞机4、飞机5满油 <br />继续飞，飞机6安全飞回O点。 <br />6、飞机1、飞机4、飞机5同时飞到F点，此时刻各加飞机的油料为 <br />     飞机1——0        飞机4——3/4        飞机5——3/4 <br />这下就方便了，飞机4和飞机5分别给飞机1一点点1/4的油料，三架飞机就安全的飞回O点了 <br />。 <br />至此，飞机1完成了环球飞行，并且其他飞机也都安全到达起飞点，总共派出了6架飞机。 <br />javascript:DrawImage(this); border=0&gt; <br />五.主观题 <br />1.告诉用户我公司为答谢广大顾客长时间以来的厚爱，顾客可以持原电池免费更换使用寿命 <br />为原电池一倍的新型电池。或者可以持购买发票，获得50元购买该厂家新手机的折换券。 </p>
		<p>2.信件如下： <br />“xxx领导：您好！ <br />我馆近期将展出一批珍贵文物，让更多的人能够真正的体会到中华民族文明的悠久、灿烂。 <br />我们希望能将您所拥有的明代的城砖展出。并且我们将在博物馆内设置专栏，宣传您对中华 <br />民族悠久文化的保存所作出的巨大贡献，让更多的华夏子孙看到，并且亲身体验到华夏文明 <br />的悠久历史，从而加强中华民族的凝聚力！” <br />解释： <br />领导看过这封信以后，如果不拿出城砖。那么也就说明他不想让更多的人看到中华民族的灿 <br />烂文明，不想让中华民族有更强的凝聚力。自然也就会拿出城砖。如果领导问到何时展出完 <br />毕，可以告诉他博物馆希望永久展出这些物品，领导自然也就无话可说了。 <br />  <br />3.信件如下： <br />“ 尊敬的顾客，您好！ <br />由于工作人员的失误，误将一台样品机卖给您。为了您能够更好的使用我公司的产品，我公 <br />司决定为您免费更换同等价位的笔记本一台。并且我们有性价比更加优越的xxxII 型笔记本 <br />电脑，售价20000元人民币。如果您此时购买，我们将会以19000元的优惠价格售出。” <br />  <br />六．算法题 <br />请参考数据结构和计算机算法类书籍，作者就不再抄书了。 <br />附（1）：烧绳子类问题总结： <br />一般给出的绳子都是不均匀的。如果一根为一小时，那么半个小时的计算方法是从两头烧。 <br />十五分钟的计算方法是从两头烧，同时从中间任何一个地方开始烧，这样这根绳子就有四个 <br />燃烧点，时间自然是一个燃烧点的四分之一。如果计算十分钟的时间，那么就让绳子有六个 <br />燃烧点，方法就不用说了吧！ <br />附（2）：天平称球问题解答以及总结： <br />将球分为a b c d； e f g h； i j k l 三组。 <br />第一次称量，比较 abcd efgh <br />情形一： <br />两者重量相等，此时说明答案在ijkl中。 <br />称量ij， <br />如果相等,说明答案在kl中。拿k与a比较，如果相等，答案为l；如果不等，答案为k。 <br />如果不等，说明答案在ij中。拿i与a比较，如果相等，答案为j；如果不等，答案为i。 <br />情形二： <br />abcd轻。 <br />在efgh中取出fgh，替换掉abcd中的bcd。 在ijkl中取出jkl，补充到原来fgh的位置。 <br />如果afgh轻，说明答案为a或e。称量ab，如果相等，答案为e；如果不等，答案为a。 <br />如果afgh重，说明答案在fgh中。称量fg，如果相等，答案为h；如果不等，重者为答案。 <br />如果一样重，答案在bcd中。称量bc，如果相等，答案为d；如果不等，轻者为答案。 <br />情形三： <br />abcd重。 <br />在efgh中取出fgh，替换掉abcd中的bcd。 在ijkl中取出jkl，补充到原来fgh的位置。 <br />如果afgh重，答案为a或e。称量ab，如果相等，答案为e；如果不等，答案为a。 <br />如果afgh轻，答案在fgh中。称量fg，如果相等，答案为h；如果不等，轻者为所求。 <br />如果一样重，答案在bcd中。称量bc，如果相等，答案为d；如果不等，重者为答案。 <br />至于13个球的称法，至今本人仍没想出来。望高手赐教。<a href="mailto:onefi@frontfree.net">onefi@frontfree.net</a><br />总结：（转载） <br />天平称重，有两个托盘比较轻重，加上托盘外面，也就是每次称重有3个结果，就是ln3/ln <br />2比特信息。n个球要知道其中一个不同的球，如果知道那个不同重量的球是轻还是重，找出 <br />来的话那就是n个结果中的一种，就是有ln（n）/ln2比特信息，如果不知道轻重，找出来就 <br />是2n（n个球中的一个，轻或者重，所以是2n）个结果中的一种，那就是ln（2n）/ln2比特 <br />信息。 <br />假设我们要称k次，根据信息理论，那显然两种情况就分别有： <br />1. k*ln3/ln2&gt;=ln（n）/ln2　（k&gt;=1）　解得k&gt;=ln（n）/ln3 <br />2. k*ln3/ln2&gt;=ln（2n）/ln2　（k&gt;1）　解得k&gt;=ln（2n）/ln3 <br />这是得到下限，可以很轻易证明满足条件的最小正整数k就是所求。比如称3次知道轻重可以 <br />从3^3=27个球中找出不同的球出来，如果不知道轻重就只能从（3^3-1）/2=13个球中找出不 <br />同的球出来。 </p>
<img src ="http://www.blogjava.net/bily/aggbug/81494.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 12:23 <a href="http://www.blogjava.net/bily/articles/81494.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JAVA代码查错</title><link>http://www.blogjava.net/bily/articles/81493.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 04:20:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81493.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81493.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81493.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81493.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81493.html</trackback:ping><description><![CDATA[<p>1. </p>
<p>abstract class Name { </p>
<p>private String name; </p>
<p>public abstract boolean isStupidName(String name) {} </p>
<p>} </p>
<p>大侠们，这有何错误? </p>
<p>答案: 错。abstract method必须以分号结尾，且不带花括号。 </p>
<p>2. </p>
<p>public class Something { </p>
<p>void doSomething () { </p>
<p>private String s = ""; </p>
<p>int l = s.length(); </p>
<p>} </p>
<p>} </p>
<p>有错吗? </p>
<p>答案: 错。局部变量前不能放置任何访问修饰符 (private，public，和protected)。final可以用来修饰局部变量 </p>
<p>(final如同abstract和strictfp，都是非访问修饰符，strictfp只能修饰class和method而非variable)。 </p>
<p>3. </p>
<p>abstract class Something { </p>
<p>private abstract String doSomething (); </p>
<p>} </p>
<p>这好像没什么错吧? </p>
<p>答案: 错。abstract的methods不能以private修饰。abstract的methods就是让子类implement(实现)具体细节的，怎么可以用private把abstract </p>
<p>method封锁起来呢? (同理，abstract method前不能加final)。 </p>
<p>4. </p>
<p>public class Something { </p>
<p>public int addOne(final int x) { </p>
<p>return ++x; </p>
<p>} </p>
<p>} </p>
<p>这个比较明显。 </p>
<p>答案: 错。int x被修饰成final，意味着x不能在addOne method中被修改。 </p>
<p>5. </p>
<p>public class Something { </p>
<p>public static void main(String[] args) { </p>
<p>Other o = new Other(); </p>
<p>new Something().addOne(o); </p>
<p>} </p>
<p>public void addOne(final Other o) { </p>
<p>o.i++; </p>
<p>} </p>
<p>} </p>
<p>class Other { </p>
<p>public int i; </p>
<p>} </p>
<p>*** 当对象作为参数传递时, 如果被声明为 final 时, 则不能改变对象参数的引用.</p>
<p>和上面的很相似，都是关于final的问题，这有错吗? </p>
<p>答案: 正确。在addOne method中，参数o被修饰成final。如果在addOne method里我们修改了o的reference </p>
<p>(比如: o = new Other();)，那么如同上例这题也是错的。但这里修改的是o的member vairable </p>
<p>(成员变量)，而o的reference并没有改变。 </p>
<p>6. </p>
<p>class Something { </p>
<p>int i; </p>
<p>public void doSomething() { </p>
<p>System.out.println("i = " + i); </p>
<p>} </p>
<p>} </p>
<p>有什么错呢? 看不出来啊。 </p>
<p>答案: 正确。输出的是"i = 0"。int i属於instant variable (实例变量，或叫成员变量)。instant variable有default value。int的default value是0。 </p>
<p>7. </p>
<p>class Something { </p>
<p>final int i; </p>
<p>public void doSomething() { </p>
<p>System.out.println("i = " + i); </p>
<p>} </p>
<p>} </p>
<p>和上面一题只有一个地方不同，就是多了一个final。这难道就错了吗? </p>
<p>答案: 错。final int i是个final的instant variable (实例变量，或叫成员变量)。final的instant variable没有default value，必须在constructor (构造器)结束之前被赋予一个明确的值。可以修改为"final int i = 0;"。 </p>
<p>8. </p>
<p>public class Something { </p>
<p>public static void main(String[] args) { </p>
<p>Something s = new Something(); </p>
<p>System.out.println("s.doSomething() returns " + doSomething()); </p>
<p>} </p>
<p>public String doSomething() { </p>
<p>return "Do something ..."; </p>
<p>} </p>
<p>} </p>
<p>看上去很完美。 </p>
<p>答案: 错。看上去在main里call doSomething没有什么问题，毕竟两个methods都在同一个class里。但仔细看，main是static的。static method不能直接call non-static methods。可改成"System.out.println("s.doSomething() returns " + s.doSomething());"。同理，static method不能访问non-static instant variable。 </p>
<p>9. </p>
<p>此处，Something类的文件名叫OtherThing.java </p>
<p>class Something { </p>
<p>private static void main(String[] something_to_do) { </p>
<p>System.out.println("Do something ..."); </p>
<p>} </p>
<p>} </p>
<p>这个好像很明显。 </p>
<p>答案: 正确。从来没有人说过Java的Class名字必须和其文件名相同。但public class的名字必须和文件名相同。 </p>
<p>10． </p>
<p>interface A{ </p>
<p>int x = 0; </p>
<p>} </p>
<p>class B{ </p>
<p>int x =1; </p>
<p>} </p>
<p>class C extends B implements A { </p>
<p>public void pX(){ </p>
<p>System.out.println(x); </p>
<p>} </p>
<p>public static void main(String[] args) { </p>
<p>new C().pX(); </p>
<p>} </p>
<p>} </p>
<p>答案：错误。在编译时会发生错误(错误描述不同的JVM有不同的信息，意思就是未明确的x调用，两个x都匹配（就象在同时import java.util和java.sql两个包时直接声明Date一样）。对于父类的变量,可以用super.x来明确，而接口的属性默认隐含为 public static final.所以可以通过A.x来明确。 </p>
<p>11. </p>
<p>interface Playable { </p>
<p>void play(); </p>
<p>} </p>
<p>interface Bounceable { </p>
<p>void play(); </p>
<p>} </p>
<p>interface Rollable extends Playable, Bounceable { </p>
<p>Ball ball = new Ball("PingPang"); </p>
<p>} </p>
<p>class Ball implements Rollable { </p>
<p>private String name; </p>
<p>public String getName() { </p>
<p>return name; </p>
<p>} </p>
<p>public Ball(String name) { </p>
<p>this.name = name; </p>
<p>} </p>
<p>public void play() { </p>
<p>ball = new Ball("Football"); </p>
<p>System.out.println(ball.getName()); </p>
<p>} </p>
<p>} </p>
<p>这个错误不容易发现。 </p>
<p>答案: 错。"interface Rollable extends Playable, Bounceable"没有问题。interface可继承多个interfaces，所以这里没错。问题出在interface Rollable里的"Ball ball = new Ball("PingPang");"。任何在interface里声明的interface variable (接口变量，也可称成员变量)，默认为public static final。也就是说"Ball ball = new Ball("PingPang");"实际上是"public static final Ball ball = new Ball("PingPang");"。在Ball类的Play()方法中，"ball = new Ball("Football");"改变了ball的reference，而这里的ball来自Rollable interface，Rollable interface里的ball是public static final的，final的object是不能被改变reference的。因此编译器将在"ball = new Ball("Football");"这里显示有错。 </p>
<p>&nbsp;</p>
<p>JAVA编程题 </p>
<p>1．现在输入n个数字，以逗号，分开；然后可选择升或者降序排序；按提交键就在另一页面显示按什么排序，结果为，提供reset </p>
<p>import java.util.*; </p>
<p>public class bycomma{ </p>
<p>public static String[] splitStringByComma(String source){ </p>
<p>if(source==null||source.trim().equals("")) </p>
<p>return null; </p>
<p>StringTokenizer commaToker = new StringTokenizer(source,","); </p>
<p>String[] result = new String[commaToker.countTokens()]; </p>
<p>int i=0; </p>
<p>while(commaToker.hasMoreTokens()){ </p>
<p>result[i] = commaToker.nextToken(); </p>
<p>i++; </p>
<p>} </p>
<p>return result; </p>
<p>} </p>
<p>public static void main(String args[]){ </p>
<p>String[] s = splitStringByComma("5,8,7,4,3,9,1"); </p>
<p>int[] ii = new int[s.length]; </p>
<p>for(int i = 0;i&lt;s.length;i++){ </p>
<p>ii[i] =Integer.parseInt(s[i]); </p>
<p>} </p>
<p>Arrays.sort(ii); </p>
<p>//asc </p>
<p>for(int i=0;i&lt;s.length;i++){ </p>
<p>System.out.println(ii[i]); </p>
<p>} </p>
<p>//desc </p>
<p>for(int i=(s.length-1);i&gt;=0;i--){ </p>
<p>System.out.println(ii[i]); </p>
<p>} </p>
<p>} </p>
<p>} </p>
<p>2．金额转换，阿拉伯数字的金额转换成中国传统的形式如：（￥1011）－&gt;（一千零一拾一元整）输出。 </p>
<p>package test.format; </p>
<p>import java.text.NumberFormat; </p>
<p>import java.util.HashMap; </p>
<p>public class SimpleMoneyFormat { </p>
<p>public static final String EMPTY = ""; </p>
<p>public static final String ZERO = "零"; </p>
<p>public static final String ONE = "壹"; </p>
<p>public static final String TWO = "贰"; </p>
<p>public static final String THREE = "叁"; </p>
<p>public static final String FOUR = "肆"; </p>
<p>public static final String FIVE = "伍"; </p>
<p>public static final String SIX = "陆"; </p>
<p>public static final String SEVEN = "柒"; </p>
<p>public static final String EIGHT = "捌"; </p>
<p>public static final String NINE = "玖"; </p>
<p>public static final String TEN = "拾"; </p>
<p>public static final String HUNDRED = "佰"; </p>
<p>public static final String THOUSAND = "仟"; </p>
<p>public static final String TEN_THOUSAND = "万"; </p>
<p>public static final String HUNDRED_MILLION = "亿"; </p>
<p>public static final String YUAN = "元"; </p>
<p>public static final String JIAO = "角"; </p>
<p>public static final String FEN = "分"; </p>
<p>public static final String DOT = "."; </p>
<p>private static SimpleMoneyFormat formatter = null; </p>
<p>private HashMap chineseNumberMap = new HashMap(); </p>
<p>private HashMap chineseMoneyPattern = new HashMap(); </p>
<p>private NumberFormat numberFormat = NumberFormat.getInstance(); </p>
<p>private SimpleMoneyFormat() { </p>
<p>numberFormat.setMaximumFractionDigits(4); </p>
<p>numberFormat.setMinimumFractionDigits(2); </p>
<p>numberFormat.setGroupingUsed(false); </p>
<p>chineseNumberMap.put("0", ZERO); </p>
<p>chineseNumberMap.put("1", ONE); </p>
<p>chineseNumberMap.put("2", TWO); </p>
<p>chineseNumberMap.put("3", THREE); </p>
<p>chineseNumberMap.put("4", FOUR); </p>
<p>chineseNumberMap.put("5", FIVE); </p>
<p>chineseNumberMap.put("6", SIX); </p>
<p>chineseNumberMap.put("7", SEVEN); </p>
<p>chineseNumberMap.put("8", EIGHT); </p>
<p>chineseNumberMap.put("9", NINE); </p>
<p>chineseNumberMap.put(DOT, DOT); </p>
<p>chineseMoneyPattern.put("1", TEN); </p>
<p>chineseMoneyPattern.put("2", HUNDRED); </p>
<p>chineseMoneyPattern.put("3", THOUSAND); </p>
<p>chineseMoneyPattern.put("4", TEN_THOUSAND); </p>
<p>chineseMoneyPattern.put("5", TEN); </p>
<p>chineseMoneyPattern.put("6", HUNDRED); </p>
<p>chineseMoneyPattern.put("7", THOUSAND); </p>
<p>chineseMoneyPattern.put("8", HUNDRED_MILLION); </p>
<p>} </p>
<p>public static SimpleMoneyFormat getInstance() { </p>
<p>if (formatter == null) </p>
<p>formatter = new SimpleMoneyFormat(); </p>
<p>return formatter; </p>
<p>} </p>
<p>public String format(String moneyStr) { </p>
<p>checkPrecision(moneyStr); </p>
<p>String result; </p>
<p>result = convertToChineseNumber(moneyStr); </p>
<p>result = addUnitsToChineseMoneyString(result); </p>
<p>return result; </p>
<p>} </p>
<p>public String format(double moneyDouble) { </p>
<p>return format(numberFormat.format(moneyDouble)); </p>
<p>} </p>
<p>public String format(int moneyInt) { </p>
<p>return format(numberFormat.format(moneyInt)); </p>
<p>} </p>
<p>public String format(long moneyLong) { </p>
<p>return format(numberFormat.format(moneyLong)); </p>
<p>} </p>
<p>public String format(Number moneyNum) { </p>
<p>return format(numberFormat.format(moneyNum)); </p>
<p>} </p>
<p>private String convertToChineseNumber(String moneyStr) { </p>
<p>String result; </p>
<p>StringBuffer cMoneyStringBuffer = new StringBuffer(); </p>
<p>for (int i = 0; i &lt; moneyStr.length(); i++) { </p>
<p>cMoneyStringBuffer.append(chineseNumberMap.get(moneyStr.substring(i, i + 1))); </p>
<p>} </p>
<p>//拾佰仟万亿等都是汉字里面才有的单位，加上它们 </p>
<p>int indexOfDot = cMoneyStringBuffer.indexOf(DOT); </p>
<p>int moneyPatternCursor = 1; </p>
<p>for (int i = indexOfDot - 1; i &gt; 0; i--) { </p>
<p>cMoneyStringBuffer.insert(i, chineseMoneyPattern.get(EMPTY + moneyPatternCursor)); </p>
<p>moneyPatternCursor = moneyPatternCursor == 8 ? 1 : moneyPatternCursor + 1; </p>
<p>} </p>
<p>String fractionPart = cMoneyStringBuffer.substring(cMoneyStringBuffer.indexOf(".")); </p>
<p>cMoneyStringBuffer.delete(cMoneyStringBuffer.indexOf("."), cMoneyStringBuffer.length()); </p>
<p>while (cMoneyStringBuffer.indexOf("零拾") != -1) { </p>
<p>cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零拾"), cMoneyStringBuffer.indexOf("零拾") + 2, ZERO); </p>
<p>} </p>
<p>while (cMoneyStringBuffer.indexOf("零佰") != -1) { </p>
<p>cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零佰"), cMoneyStringBuffer.indexOf("零佰") + 2, ZERO); </p>
<p>} </p>
<p>while (cMoneyStringBuffer.indexOf("零仟") != -1) { </p>
<p>cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零仟"), cMoneyStringBuffer.indexOf("零仟") + 2, ZERO); </p>
<p>} </p>
<p>while (cMoneyStringBuffer.indexOf("零万") != -1) { </p>
<p>cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零万"), cMoneyStringBuffer.indexOf("零万") + 2, TEN_THOUSAND); </p>
<p>} </p>
<p>while (cMoneyStringBuffer.indexOf("零亿") != -1) { </p>
<p>cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零亿"), cMoneyStringBuffer.indexOf("零亿") + 2, HUNDRED_MILLION); </p>
<p>} </p>
<p>while (cMoneyStringBuffer.indexOf("零零") != -1) { </p>
<p>cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零零"), cMoneyStringBuffer.indexOf("零零") + 2, ZERO); </p>
<p>} </p>
<p>if (cMoneyStringBuffer.lastIndexOf(ZERO) == cMoneyStringBuffer.length() - 1) </p>
<p>cMoneyStringBuffer.delete(cMoneyStringBuffer.length() - 1, cMoneyStringBuffer.length()); </p>
<p>cMoneyStringBuffer.append(fractionPart); </p>
<p>result = cMoneyStringBuffer.toString(); </p>
<p>return result; </p>
<p>} </p>
<p>private String addUnitsToChineseMoneyString(String moneyStr) {&nbsp;&nbsp;<br />
String result; StringBuffer cMoneyStringBuffer = new StringBuffer(moneyStr);<br />
&nbsp;int indexOfDot = cMoneyStringBuffer.indexOf(DOT);&nbsp;&nbsp;<br />
cMoneyStringBuffer.replace(indexOfDot, indexOfDot + 1, YUAN); <br />
cMoneyStringBuffer.insert(cMoneyStringBuffer.length() - 1, JIAO); <br />
cMoneyStringBuffer.insert(cMoneyStringBuffer.length(), FEN);<br />
&nbsp;if (cMoneyStringBuffer.indexOf("零角零分") != -1)//没有零头，加整<br />
&nbsp;&nbsp;cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零角零分"), cMoneyStringBuffer.length(), "整"); <br />
else&nbsp;&nbsp;if (cMoneyStringBuffer.indexOf("零分") != -1)//没有零分，加整&nbsp;&nbsp;&nbsp;<br />
cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("零分"), cMoneyStringBuffer.length(), "整");<br />
&nbsp;else { if(cMoneyStringBuffer.indexOf("零角")!=-1)<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;cMoneyStringBuffer.delete(cMoneyStringBuffer.indexOf("零角"),cMoneyStringBuffer.indexOf("零角")+2);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cMoneyStringBuffer.append("整"); <br />
}&nbsp;&nbsp;<br />
result = cMoneyStringBuffer.toString(); <br />
return result; <br />
} <br />
private void checkPrecision(String moneyStr) {<br />
int fractionDigits = moneyStr.length() - moneyStr.indexOf(DOT) - 1;&nbsp;<br />
&nbsp;if (fractionDigits &gt; 2)&nbsp;&nbsp;throw new RuntimeException("金额" + moneyStr + "的小数位多于两位。"); //精度不能比分低&nbsp;&nbsp;<br />
}<br />
public static void main(String args[]) {&nbsp;&nbsp;<br />
System.out.println(getInstance().format(new Double(10010001.01))); <br />
}<br />
}<br />
<br />
3、继承时候类的执行顺序问题,一般都是选择题,问你将会打印出什么? <br />
答:父类： package test; <br />
public class FatherClass { <br />
public FatherClass() { <br />
System.out.println("FatherClass Create"); <br />
} <br />
} <br />
子类: package test; <br />
import test.FatherClass; <br />
public class ChildClass extends FatherClass { <br />
public ChildClass() { <br />
System.out.println("ChildClass Create"); <br />
} <br />
public static void main(String[] args) { <br />
FatherClass fc = new FatherClass(); <br />
ChildClass cc = new ChildClass(); <br />
} <br />
} <br />
输出结果： C:&gt;java test.ChildClass&nbsp;&nbsp;FatherClass Create&nbsp; &nbsp;FatherClass Create&nbsp; &nbsp;ChildClass Create <br />
<br />
4、内部类的实现方式? <br />
答：示例代码如下： <br />
package test; <br />
public class OuterClass { <br />
private class InterClass { <br />
public InterClass() { <br />
System.out.println("InterClass Create"); <br />
} <br />
} <br />
public OuterClass() { <br />
InterClass ic = new InterClass(); <br />
System.out.println("OuterClass Create"); <br />
} <br />
public static void main(String[] args) { <br />
OuterClass oc = new OuterClass(); <br />
} <br />
}<br />
&nbsp;输出结果: C:&gt;java test/OuterClass <br />
InterClass Create&nbsp; &nbsp;OuterClass Create <br />
再一个例题： <br />
public class OuterClass {<br />
&nbsp;private double d1 = 1.0; <br />
//insert code here <br />
} <br />
You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.) <br />
A. class InnerOne{ public static double methoda() {return d1;} } <br />
B. public class InnerOne{ static double methoda() {return d1;} } <br />
C. private class InnerOne{ double methoda() {return d1;} } <br />
D. static class InnerOne{ protected double methoda() {return d1;} } <br />
E. abstract class InnerOne{ public abstract double methoda(); } <br />
<br />
说明如下： 一.静态内部类可以有静态成员，而非静态内部类则不能有静态成员。 故 A、B 错 二.静态内部类的非静态成员可以访问外部类的静态变量，而不可访问外部类的非静态变量；return d1 出错。故 D 错 三.非静态内部类的非静态成员可以访问外部类的非静态变量。 故 C 正确 四.答案为C、E <br />
<br />
5、Java 的通信编程，编程题(或问答)，用JAVA SOCKET编程，读服务器几个字符，再写入本地显示？ <br />
答:Server端程序: <br />
package test; <br />
import java.net.*; <br />
import java.io.*; <br />
public class Server { <br />
private ServerSocket ss; <br />
private Socket socket; <br />
private BufferedReader in; <br />
private PrintWriter out; <br />
public Server() { <br />
try { <br />
ss=new ServerSocket(10000); <br />
while(true) { <br />
socket = ss.accept(); <br />
String RemoteIP = socket.getInetAddress().getHostAddress(); <br />
String RemotePort = ":"+socket.getLocalPort(); <br />
System.out.println("A client come in!IP:"+RemoteIP+RemotePort); <br />
in = new BufferedReader(new InputStreamReader(socket.getInputStream())); <br />
String line = in.readLine(); <br />
System.out.println("Cleint send is :" + line); <br />
out = new PrintWriter(socket.getOutputStream(),true); <br />
out.println("Your Message Received!"); <br />
out.close(); <br />
in.close(); <br />
socket.close(); <br />
} <br />
}catch (IOException e) { <br />
out.println("wrong"); <br />
} <br />
} <br />
public static void main(String[] args) { <br />
new Server(); <br />
} <br />
} <br />
Client端程序: <br />
package test; import java.io.*; <br />
import java.net.*; <br />
public class Client { <br />
Socket socket; <br />
BufferedReader in; <br />
PrintWriter out; <br />
public Client() { <br />
try { <br />
System.out.println("Try to Connect to 127.0.0.1:10000"); <br />
socket = new Socket("127.0.0.1",10000); <br />
System.out.println("The Server Connected!"); <br />
System.out.println("Please enter some Character:"); <br />
BufferedReader line = new BufferedReader(new InputStreamReader(System.in)); <br />
out = new PrintWriter(socket.getOutputStream(),true); <br />
Out<br />
<br />
6、 forward和rederect的区别<br />
答：redirect重定向到另外一个页面，重新开始一个请求forward跳转到另外一个页面， 请求不断开<br />
<br />
7、 jsp的常用的命令<br />
答：page, include, talib, forward,<br />
<br />
8、 接口和内部类、抽象类的特征<br />
答：接口：在一个类里，只有申明没有实现。内部类：是在一个类的内部定义的一个类；抽象类：是以abstract 定义的，里面至少有一个抽象方法。<br />
<br />
9、 文件读写的基本类<br />
答：File Reader 类和FileWriter类分别继承自Reader类和Writer类。FileReader类用于读取文件，File Writer类用于将数据写入文件，这两各类在使用前，都必须要调用其构造方法创建相应的对象，然后调用相应的read()或 write()方法。<br />
<br />
10、 串行化的注意事项以及如何实现串行化<br />
答：如果有循环引用是不可以串行化的。对象输出流的WriteObject方法和 对象输入流的ReadObect 方法<br />
<br />
11、 线程的基本概念、线程的本状态以及状态之间的关系<br />
&#8226;新建 (Born) : 新建的线程处于新建状态<br />
&#8226;就绪 (Ready) : 在创建线程后，它将处于就绪状态，等待 start() 方法被调用<br />
&#8226;运行 (Running) : 线程在开始执行时进入运行状态<br />
&#8226;睡眠 (Sleeping) : 线程的执行可通过使用 sleep() 方法来暂时中止。在睡眠后，线程将进入就绪状态<br />
&#8226;等待 (Waiting) : 如果调用了 wait() 方法，线程将处于等待状态。用于在两个或多个线程并发运行时。<br />
&#8226;挂起 (Suspended) : 在临时停止或中断线程的执行时，线程就处于挂起状态。<br />
&#8226;恢复 (Resume) : 在挂起的线程被恢复执行时，可以说它已被恢复。<br />
&#8226;阻塞 (Blocked) &#8211; 在线程等待一个事件时（例如输入/输出操作），就称其处于阻塞状态。<br />
&#8226;死亡 (Dead) &#8211; 在 run() 方法已完成执行或其 stop() 方法被调用之后，线程就处于死亡状态。<br />
&nbsp; <br />
12、 线程的同步、如何实现线程的同步<br />
答：当两个或多个线程同时访问同一个变量，并且以个线程需要修改这个变量。就要用到线程同步。在Java 中，同步是通过 synchronized 关键字来定义的。 诺是想同步化某程序段，可以使用 synchronized(object){}方法，其中{}内的程序语句被同步化。<br />
<br />
13、 socket通信（tcp/udp区别及JAVA的实现方式）<br />
TCP——传输控制协议，具有极高的可靠性，保证数据包按照顺序准确到达，但其也有着很高的额外负担。<br />
UDP——使用者数据元协议，并不能保证数据包会被成功的送达，也不保证数据包到达的顺序，但其传输速度很快。大多数我们会使用TCP，偶尔才会动用UDP，如声音讯号，即使少量遗失，也无关紧要。<br />
<br />
14、 JAVA的事件委托机制和垃圾回收机制<br />
java 事件委托机制的概念,一个源产生一个事件并将它送到一个或多个监听器那里。在这种方案中，监听器简单的等待，直到它收到一个事件。一旦事件被接受，监听器将处理这个事件，然后返回。垃圾回收机制 垃圾收集是将分配给对象但不在使用的内存回收或释放的过程。如果一个对象没有指向它的引用或者其赋值为null,则次对象适合进行垃圾回收<br />
<br />
15、 JDBC调用数据库的基本步骤<br />
导入必要的类，装入JDBC驱动程序，识别数据源，分配一个Connection对象，分配一个Statement对象，使用Statement执行一个查询，从返回的ResultSet对象中检索数据，关闭ResultSet，关闭Statement对象，关闭Connection对象<br />
<br />
16、 解析XML文件的几种方式和区别<br />
答：Dom解析 在内存中创建一个DOM树，能随机访问文件内容，也可以修改原文件内容SAX解析 线性解析，不能随机访问，也无法修改原文件Dom解析要先用SAX解析创建DOM树<br />
<br />
17、 JAVA的四种基本权限的定义public private protected 默认<br />
<br />
18、 JAVA的国际化&nbsp;&nbsp;<br />
答：Java 中提供了诺干国际化明感类，来实现国际化的。例如：dateformat&nbsp;&nbsp;timezone 等等。</p>
<img src ="http://www.blogjava.net/bily/aggbug/81493.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 12:20 <a href="http://www.blogjava.net/bily/articles/81493.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java面试题集（二）</title><link>http://www.blogjava.net/bily/articles/81478.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 03:27:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81478.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81478.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81478.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81478.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81478.html</trackback:ping><description><![CDATA[
		<p>1、面向对象的特征有哪些方面 </p>
		<p>1.抽象： </p>
		<p>抽象就是忽略一个主题中与当前目标无关的那些方面，以便更充分地注意与当前目标有关的方面。抽象并不打算了解全部问题，而只是选择其中的一部分，暂时不用部分细节。抽象包括两个方面，一是过程抽象，二是数据抽象。 </p>
		<p>2.继承： </p>
		<p>继承是一种联结类的层次模型，并且允许和鼓励类的重用，它提供了一种明确表述共性的方法。对象的一个新类可以从现有的类中派生，这个过程称为类继承。新类继承了原始类的特性，新类称为原始类的派生类（子类），而原始类称为新类的基类（父类）。派生类可以从它的基类那里继承方法和实例变量，并且类可以修改或增加新的方法使之更适合特殊的需要。 </p>
		<p>3.封装： </p>
		<p>封装是把过程和数据包围起来，对数据的访问只能通过已定义的界面。面向对象计算始于这个基本概念，即现实世界可以被描绘成一系列完全自治、封装的对象，这些对象通过一个受保护的接口访问其他对象。 </p>
		<p>4. 多态性： </p>
		<p>多态性是指允许不同类的对象对同一消息作出响应。多态性包括参数化多态性和包含多态性。多态性语言具有灵活、抽象、行为共享、代码共享的优势，很好的解决了应用程序函数同名问题。 </p>
		<p>2、String是最基本的数据类型吗? </p>
		<p>基本数据类型包括byte、int、char、long、float、double、boolean和short。 </p>
		<p>java.lang.String类是final类型的，因此不可以继承这个类、不能修改这个类。为了提高效率节省空间，我们应该用StringBuffer类 </p>
		<p>3、int 和 Integer 有什么区别 </p>
		<p>Java 提供两种不同的类型：引用类型和原始类型（或内置类型）。Int是java的原始数据类型，Integer是java为int提供的封装类。Java为每个原始类型提供了封装类。 </p>
		<p>原始类型封装类 </p>
		<p>booleanBoolean </p>
		<p>charCharacter </p>
		<p>byteByte </p>
		<p>shortShort </p>
		<p>intInteger </p>
		<p>longLong </p>
		<p>floatFloat </p>
		<p>doubleDouble </p>
		<p>引用类型和原始类型的行为完全不同，并且它们具有不同的语义。引用类型和原始类型具有不同的特征和用法，它们包括：大小和速度问题，这种类型以哪种类型的数据结构存储，当引用类型和原始类型用作某个类的实例数据时所指定的缺省值。对象引用实例变量的缺省值为 null，而原始类型实例变量的缺省值与它们的类型有关。 </p>
		<p>4、String 和StringBuffer的区别 </p>
		<p>JAVA平台提供了两个类：String和StringBuffer，它们可以储存和操作字符串，即包含多个字符的字符数据。这个String类提供了数值不可改变的字符串。而这个StringBuffer类提供的字符串进行修改。当你知道字符数据要改变的时候你就可以使用StringBuffer。典型地，你可以使用StringBuffers来动态构造字符数据。 </p>
		<p>5、运行时异常与一般异常有何异同？ </p>
		<p>异常表示程序运行过程中可能出现的非正常状态，运行时异常表示虚拟机的通常操作中可能遇到的异常，是一种常见运行错误。java编译器要求方法必须声明抛出可能发生的非运行时异常，但是并不要求必须声明抛出未被捕获的运行时异常。 </p>
		<p>6、说出Servlet的生命周期，并说出Servlet和CGI的区别。 </p>
		<p>Servlet被服务器实例化后，容器运行其init方法，请求到达时运行其service方法，service方法自动派遣运行与请求对应的doXXX方法（doGet，doPost）等，当服务器决定将实例销毁的时候调用其destroy方法。 </p>
		<p>与cgi的区别在于servlet处于服务器进程中，它通过多线程方式运行其service方法，一个实例可以服务于多个请求，并且其实例一般不会销毁，而CGI对每个请求都产生新的进程，服务完成后就销毁，所以效率上低于servlet。 </p>
		<p>7、说出ArrayList,Vector, LinkedList的存储性能和特性 </p>
		<p>ArrayList和Vector都是使用数组方式存储数据，此数组元素数大于实际存储的数据以便增加和插入元素，它们都允许直接按序号索引元素，但是插入元素要涉及数组元素移动等内存操作，所以索引数据快而插入数据慢，Vector由于使用了synchronized方法（线程安全），通常性能上较ArrayList差，而LinkedList使用双向链表实现存储，按序号索引数据需要进行前向或后向遍历，但是插入数据时只需要记录本项的前后项即可，所以插入速度较快。 </p>
		<p>8、EJB是基于哪些技术实现的？并说出SessionBean和EntityBean的区别，StatefulBean和StatelessBean的区别。 </p>
		<p>EJB包括Session Bean、Entity Bean、Message Driven Bean，基于JNDI、RMI、JAT等技术实现。 </p>
		<p>SessionBean在J2EE应用程序中被用来完成一些服务器端的业务操作，例如访问数据库、调用其他EJB组件。EntityBean被用来代表应用系统中用到的数据。 </p>
		<p>对于客户机，SessionBean是一种非持久性对象，它实现某些在服务器上运行的业务逻辑。 </p>
		<p>对于客户机，EntityBean是一种持久性对象，它代表一个存储在持久性存储器中的实体的对象视图，或是一个由现有企业应用程序实现的实体。 </p>
		<p>Session Bean 还可以再细分为 Stateful Session Bean 与 Stateless Session Bean ，这两种的 Session Bean都可以将系统逻辑放在 method之中执行，不同的是 Stateful Session Bean 可以记录呼叫者的状态，因此通常来说，一个使用者会有一个相对应的 Stateful Session Bean 的实体。Stateless Session Bean 虽然也是逻辑组件，但是他却不负责记录使用者状态，也就是说当使用者呼叫 Stateless Session Bean 的时候，EJB Container 并不会找寻特定的 Stateless Session Bean 的实体来执行这个 method。换言之，很可能数个使用者在执行某个 Stateless Session Bean 的 methods 时，会是同一个 Bean 的 Instance 在执行。从内存方面来看， Stateful Session Bean 与 Stateless Session Bean 比较， Stateful Session Bean 会消耗 J2EE Server 较多的内存，然而 Stateful Session Bean 的优势却在于他可以维持使用者的状态。 </p>
		<p>9、Collection 和 Collections的区别。 </p>
		<p>　　Collection是集合类的上级接口，继承与他的接口主要有Set 和List. </p>
		<p>Collections是针对集合类的一个帮助类，他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。 </p>
		<p>10、&amp;和&amp;&amp;的区别。 </p>
		<p>&amp;是位运算符，表示按位与运算，&amp;&amp;是逻辑运算符，表示逻辑与（and）。 </p>
		<p>11、HashMap和Hashtable的区别。 </p>
		<p>HashMap是Hashtable的轻量级实现（非线程安全的实现），他们都完成了Map接口，主要区别在于HashMap允许空（null）键值（key）,由于非线程安全，效率上可能高于Hashtable。 </p>
		<p>HashMap允许将null作为一个entry的key或者value，而Hashtable不允许。 </p>
		<p>HashMap把Hashtable的contains方法去掉了，改成containsvalue和containsKey。因为contains方法容易让人引起误解。 </p>
		<p>Hashtable继承自Dictionary类，而HashMap是Java1.2引进的Map interface的一个实现。 </p>
		<p>最大的不同是，Hashtable的方法是Synchronize的，而HashMap不是，在多个线程访问Hashtable时，不需要自己为它的方法实现同步，而HashMap 就必须为之提供外同步。 </p>
		<p>Hashtable和HashMap采用的hash/rehash算法都大概一样，所以性能不会有很大的差异。 </p>
		<p>12、final, finally, finalize的区别。 </p>
		<p>　　final 用于声明属性，方法和类，分别表示属性不可变，方法不可覆盖，类不可继承。 </p>
		<p>finally是异常处理语句结构的一部分，表示总是执行。 </p>
		<p>finalize是Object类的一个方法，在垃圾收集器执行的时候会调用被回收对象的此方法，可以覆盖此方法提供垃圾收集时的其他资源回收，例如关闭文件等。 </p>
		<p>13、sleep() 和 wait() 有什么区别? </p>
		<p>sleep是线程类（Thread）的方法，导致此线程暂停执行指定时间，给执行机会给其他线程，但是监控状态依然保持，到时后会自动恢复。调用sleep不会释放对象锁。 </p>
		<p>wait是Object类的方法，对此对象调用wait方法导致本线程放弃对象锁，进入等待此对象的等待锁定池，只有针对此对象发出notify方法（或notifyAll）后本线程才进入对象锁定池准备获得对象锁进入运行状态。 </p>
		<p>14、Overload和Override的区别。Overloaded的方法是否可以改变返回值的类型? </p>
		<p>方法的重写Overriding和重载Overloading是Java多态性的不同表现。重写Overriding是父类与子类之间多态性的一种表现，重载Overloading是一个类中多态性的一种表现。如果在子类中定义某方法与其父类有相同的名称和参数，我们说该方法被重写 (Overriding)。子类的对象使用这个方法时，将调用子类中的定义，对它而言，父类中的定义如同被"屏蔽"了。如果在一个类中定义了多个同名的方法，它们或有不同的参数个数或有不同的参数类型，则称为方法的重载(Overloading)。Overloaded的方法是可以改变返回值的类型。 </p>
		<p>15、error和exception有什么区别? </p>
		<p>error 表示恢复不是不可能但很困难的情况下的一种严重问题。比如说内存溢出。不可能指望程序能处理这样的情况。 </p>
		<p>exception 表示一种设计或实现问题。也就是说，它表示如果程序运行正常，从不会发生的情况。 </p>
		<p>16、同步和异步有何异同，在什么情况下分别使用他们？举例说明。 </p>
		<p>如果数据将在线程间共享。例如正在写的数据以后可能被另一个线程读到，或者正在读的数据可能已经被另一个线程写过了，那么这些数据就是共享数据，必须进行同步存取。 </p>
		<p>当应用程序在对象上调用了一个需要花费很长时间来执行的方法，并且不希望让程序等待方法的返回时，就应该使用异步编程，在很多情况下采用异步途径往往更有效率。 </p>
		<p>17、abstract class和interface有什么区别? </p>
		<p>声明方法的存在而不去实现它的类被叫做抽象类（abstract class），它用于要创建一个体现某些基本行为的类，并为该类声明方法，但不能在该类中实现该类的情况。不能创建abstract 类的实例。然而可以创建一个变量，其类型是一个抽象类，并让它指向具体子类的一个实例。不能有抽象构造函数或抽象静态方法。Abstract 类的子类为它们父类中的所有抽象方法提供实现，否则它们也是抽象类为。取而代之，在子类中实现该方法。知道其行为的其它类可以在类中实现这些方法。 </p>
		<p>接口（interface）是抽象类的变体。在接口中，所有方法都是抽象的。多继承性可通过实现这样的接口而获得。接口中的所有方法都是抽象的，没有一个有程序体。接口只可以定义static final成员变量。接口的实现与子类相似，除了该实现类不能从接口定义中继承行为。当类实现特殊接口时，它定义（即将程序体给予）所有这种接口的方法。然后，它可以在实现了该接口的类的任何对象上调用接口的方法。由于有抽象类，它允许使用接口名作为引用变量的类型。通常的动态联编将生效。引用可以转换到接口类型或从接口类型转换，instanceof 运算符可以用来决定某对象的类是否实现了接口。 </p>
		<p>18、heap和stack有什么区别。 </p>
		<p>栈是一种线形集合，其添加和删除元素的操作应在同一段完成。栈按照后进先出的方式进行处理。 </p>
		<p>堆是栈的一个组成元素 </p>
		<p>19、forward 和redirect的区别 </p>
		<p>forward是服务器请求资源，服务器直接访问目标地址的URL，把那个URL的响应内容读取过来，然后把这些内容再发给浏览器，浏览器根本不知道服务器发送的内容是从哪儿来的，所以它的地址栏中还是原来的地址。 </p>
		<p>redirect就是服务端根据逻辑,发送一个状态码,告诉浏览器重新去请求那个地址，一般来说浏览器会用刚才请求的所有参数重新请求，所以session,request参数都可以获取。 </p>
		<p>20、EJB与JAVA BEAN的区别？ </p>
		<p>Java Bean 是可复用的组件，对Java Bean并没有严格的规范，理论上讲，任何一个Java类都可以是一个Bean。但通常情况下，由于Java Bean是被容器所创建（如Tomcat）的，所以Java Bean应具有一个无参的构造器，另外，通常Java Bean还要实现Serializable接口用于实现Bean的持久性。Java Bean实际上相当于微软COM模型中的本地进程内COM组件，它是不能被跨进程访问的。Enterprise Java Bean 相当于DCOM，即分布式组件。它是基于Java的远程方法调用（RMI）技术的，所以EJB可以被远程访问（跨进程、跨计算机）。但EJB必须被布署在诸如Webspere、WebLogic这样的容器中，EJB客户从不直接访问真正的EJB组件，而是通过其容器访问。EJB容器是EJB组件的代理，EJB组件由容器所创建和管理。客户通过容器来访问真正的EJB组件。 </p>
		<p>21、Static Nested Class 和 Inner Class的不同。 </p>
		<p>Static Nested Class是被声明为静态（static）的内部类，它可以不依赖于外部类实例被实例化。而通常的内部类需要在外部类实例化后才能实例化。 </p>
		<p>22、JSP中动态INCLUDE与静态INCLUDE的区别？ </p>
		<p>动态INCLUDE用jsp:include动作实现 &lt;jsp:include page="included.jsp" flush="true" /&gt;它总是会检查所含文件中的变化，适合用于包含动态页面，并且可以带参数。 </p>
		<p>静态INCLUDE用include伪码实现,定不会检查所含文件的变化，适用于包含静态页面&lt;%@ include file="included.htm" %&gt; </p>
		<p>23、什么时候用assert。 </p>
		<p>assertion(断言)在软件开发中是一种常用的调试方式，很多开发语言中都支持这种机制。在实现中，assertion就是在程序中的一条语句，它对一个boolean表达式进行检查，一个正确程序必须保证这个boolean表达式的值为true；如果该值为false，说明程序已经处于不正确的状态下，系统将给出警告或退出。一般来说，assertion用于保证程序最基本、关键的正确性。assertion检查通常在开发和测试时开启。为了提高性能，在软件发布后，assertion检查通常是关闭的。 </p>
		<p>24、GC是什么? 为什么要有GC? </p>
		<p>　　GC是垃圾收集的意思（Gabage Collection）,内存处理是编程人员容易出现问题的地方，忘记或者错误的内存回收会导致程序或系统的不稳定甚至崩溃，Java提供的GC功能可以自动监测对象是否超过作用域从而达到自动回收内存的目的，Java语言没有提供释放已分配内存的显示操作方法。 </p>
		<p>25、short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错? </p>
		<p>short s1 = 1; s1 = s1 + 1; （s1+1运算结果是int型，需要强制转换类型） </p>
		<p>short s1 = 1; s1 += 1;（可以正确编译） </p>
		<p>26、Math.round(11.5)等於多少? Math.round(-11.5)等於多少? </p>
		<p>Math.round(11.5)==12 </p>
		<p>Math.round(-11.5)==-11 </p>
		<p>round方法返回与参数最接近的长整数，参数加1/2后求其floor. </p>
		<p>27、String s = new String("xyz");创建了几个String Object? </p>
		<p>两个 </p>
		<p>28、设计4个线程，其中两个线程每次对j增加1，另外两个线程对j每次减少1。写出程序。 </p>
		<p>以下程序使用内部类实现线程，对j增减的时候没有考虑顺序问题。 </p>
		<p>public class ThreadTest1{ </p>
		<p>private int j; </p>
		<p>public static void main(String args[]){ </p>
		<p>ThreadTest1 tt=new ThreadTest1(); </p>
		<p>Inc inc=tt.new Inc(); </p>
		<p>Dec dec=tt.new Dec(); </p>
		<p>for(int i=0;i&lt;2;i++){ </p>
		<p>Thread t=new Thread(inc); </p>
		<p>t.start(); </p>
		<p>t=new Thread(dec); </p>
		<p>t.start(); </p>
		<p>} </p>
		<p>} </p>
		<p>private synchronized void inc(){ </p>
		<p>j++; </p>
		<p>System.out.println(Thread.currentThread().getName()+"-inc:"+j); </p>
		<p>} </p>
		<p>private synchronized void dec(){ </p>
		<p>j--; </p>
		<p>System.out.println(Thread.currentThread().getName()+"-dec:"+j); </p>
		<p>} </p>
		<p>class Inc implements Runnable{ </p>
		<p>public void run(){ </p>
		<p>for(int i=0;i&lt;100;i++){ </p>
		<p>inc(); </p>
		<p>} </p>
		<p>} </p>
		<p>} </p>
		<p>class Dec implements Runnable{ </p>
		<p>public void run(){ </p>
		<p>for(int i=0;i&lt;100;i++){ </p>
		<p>dec(); </p>
		<p>} </p>
		<p>} </p>
		<p>} </p>
		<p>} </p>
		<p>29、Java有没有goto? </p>
		<p>java中的保留字，现在没有在java中使用。 </p>
		<p>30、启动一个线程是用run()还是start()? </p>
		<p>启动一个线程是调用start()方法，使线程所代表的虚拟处理机处于可运行状态，这意味着它可以由JVM调度并执行。这并不意味着线程就会立即运行。run()方法可以产生必须退出的标志来停止一个线程。 </p>
		<p> </p>
		<p>31、EJB包括（SessionBean,EntityBean）说出他们的生命周期，及如何管理事务的？ </p>
		<p>SessionBean：Stateless Session Bean 的生命周期是由容器决定的，当客户机发出请求要建立一个Bean的实例时，EJB容器不一定要创建一个新的Bean的实例供客户机调用，而是随便找一个现有的实例提供给客户机。当客户机第一次调用一个Stateful Session Bean 时，容器必须立即在服务器中创建一个新的Bean实例，并关联到客户机上，以后此客户机调用Stateful Session Bean 的方法时容器会把调用分派到与此客户机相关联的Bean实例。 </p>
		<p>EntityBean：Entity Beans能存活相对较长的时间，并且状态是持续的。只要数据库中的数据存在，Entity beans就一直存活。而不是按照应用程序或者服务进程来说的。即使EJB容器崩溃了，Entity beans也是存活的。Entity Beans生命周期能够被容器或者 Beans自己管理。 </p>
		<p>EJB通过以下技术管理实务：对象管理组织（OMG）的对象实务服务（OTS），Sun Microsystems的Transaction Service（JTS）、Java Transaction API（JTA），开发组（X/Open）的XA接口。 </p>
		<p>32、应用服务器有那些？ </p>
		<p>BEA WebLogic Server，IBM WebSphere Application Server，Oracle9i Application Server，jBoss，Tomcat </p>
		<p>33、给我一个你最常见到的runtime exception。 </p>
		<p>ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFormatException, SecurityException, SystemException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException </p>
		<p>34、接口是否可继承接口? 抽象类是否可实现(implements)接口? 抽象类是否可继承实体类(concrete class)? </p>
		<p>接口可以继承接口。抽象类可以实现(implements)接口，抽象类可继承实体类 </p>
		<p>35、List, Set, Map是否继承自Collection接口? </p>
		<p>List，Set是，Map不是 </p>
		<p>36、说出数据连接池的工作机制是什么? </p>
		<p>J2EE服务器启动时会建立一定数量的池连接，并一直维持不少于此数目的池连接。客户端程序需要连接时，池驱动程序会返回一个未使用的池连接并将其表记为忙。如果当前没有空闲连接，池驱动程序就新建一定数量的连接，新建连接的数量有配置参数决定。当使用的池连接调用完成后，池驱动程序将此连接表记为空闲，其他调用就可以使用这个连接。 </p>
		<p>37、abstract的method是否可同时是static,是否可同时是native，是否可同时是synchronized? </p>
		<p>都不能 </p>
		<p>38、数组有没有length()这个方法? String有没有length()这个方法？ </p>
		<p>数组没有length()这个方法，有length的属性。String有有length()这个方法。 </p>
		<p>39、Set里的元素是不能重复的，那么用什么方法来区分重复与否呢? 是用==还是equals()? 它们有何区别? </p>
		<p>Set里的元素是不能重复的，那么用iterator()方法来区分重复与否。equals()是判读两个Set是否相等。 </p>
		<p>equals()和==方法决定引用值是否指向同一对象equals()在类中被覆盖，为的是当两个分离的对象的内容和类型相配的话，返回真值。 </p>
		<p>40、构造器Constructor是否可被override? </p>
		<p>构造器Constructor不能被继承，因此不能重写Overriding，但可以被重载Overloading。 </p>
		<p>41、是否可以继承String类? </p>
		<p>String类是final类故不可以继承。 </p>
		<p>42、swtich是否能作用在byte上，是否能作用在long上，是否能作用在String上? </p>
		<p>switch（expr1）中，expr1是一个整数表达式。因此传递给 switch 和 case 语句的参数应该是 int、 short、 char 或者 byte。long,string 都不能作用于swtich。 </p>
		<p>43、try {}里有一个return语句，那么紧跟在这个try后的finally {}里的code会不会被执行，什么时候被执行，在return前还是后? </p>
		<p>会执行，在return前执行。 </p>
		<p>44、编程题: 用最有效率的方法算出2乘以8等於几? </p>
		<p>2 &lt;&lt; 3 </p>
		<p>45、两个对象值相同(x.equals(y) == true)，但却可有不同的hash code，这句话对不对? </p>
		<p>不对，有相同的hash code。 </p>
		<p>46、当一个对象被当作参数传递到一个方法后，此方法可改变这个对象的属性，并可返回变化后的结果，那么这里到底是值传递还是引用传递? </p>
		<p>是值传递。Java 编程语言只有值传递参数。当一个对象实例作为一个参数被传递到方法中时，参数的值就是对该对象的引用。对象的内容可以在被调用的方法中改变，但对象的引用是永远不会改变的。 </p>
		<p>47、当一个线程进入一个对象的一个synchronized方法后，其它线程是否可进入此对象的其它方法? </p>
		<p>不能，一个对象的一个synchronized方法只能由一个线程访问。 </p>
		<p>48、编程题: 写一个Singleton出来。 </p>
		<p>Singleton模式主要作用是保证在Java应用程序中，一个类Class只有一个实例存在。 </p>
		<p>一般Singleton模式通常有几种种形式: </p>
		<p>第一种形式: 定义一个类，它的构造函数为private的，它有一个static的private的该类变量，在类初始化时实例话，通过一个public的getInstance方法获取对它的引用,继而调用其中的方法。 </p>
		<p>public class Singleton { </p>
		<p>private Singleton(){} </p>
		<p>　　 //在自己内部定义自己一个实例，是不是很奇怪？ </p>
		<p>　　 //注意这是private 只供内部调用 </p>
		<p>　　 private static Singleton instance = new Singleton(); </p>
		<p>　　 //这里提供了一个供外部访问本class的静态方法，可以直接访问　　 </p>
		<p>　　 public static Singleton getInstance() { </p>
		<p>　　　　 return instance; 　　 </p>
		<p>　　 } </p>
		<p>} </p>
		<p>第二种形式: </p>
		<p>public class Singleton { </p>
		<p>　　private static Singleton instance = null; </p>
		<p>　　public static synchronized Singleton getInstance() { </p>
		<p>　　//这个方法比上面有所改进，不用每次都进行生成对象，只是第一次　　　 　 </p>
		<p>　　//使用时生成实例，提高了效率！ </p>
		<p>　　if (instance==null) </p>
		<p>　　　　instance＝new Singleton(); </p>
		<p>return instance; 　　} </p>
		<p>} </p>
		<p>其他形式: </p>
		<p>定义一个类，它的构造函数为private的，所有方法为static的。 </p>
		<p>一般认为第一种形式要更加安全些 </p>
		<p>49、Java的接口和C++的虚类的相同和不同处。 </p>
		<p>由于Java不支持多继承，而有可能某个类或对象要使用分别在几个类或对象里面的方法或属性，现有的单继承机制就不能满足要求。与继承相比，接口有更高的灵活性，因为接口中没有任何实现代码。当一个类实现了接口以后，该类要实现接口里面所有的方法和属性，并且接口里面的属性在默认状态下面都是public static,所有方法默认情况下是public.一个类可以实现多个接口。 </p>
		<p>50、Java中的异常处理机制的简单原理和应用。 </p>
		<p>当JAVA程序违反了JAVA的语义规则时，JAVA虚拟机就会将发生的错误表示为一个异常。违反语义规则包括2种情况。一种是JAVA类库内置的语义检查。例如数组下标越界,会引发IndexOutOfBoundsException;访问null的对象时会引发NullPointerException。另一种情况就是JAVA允许程序员扩展这种语义检查，程序员可以创建自己的异常，并自由选择在何时用throw关键字引发异常。所有的异常都是java.lang.Thowable的子类。 </p>
		<p>51、垃圾回收的优点和原理。并考虑2种回收机制。 </p>
		<p>Java语言中一个显著的特点就是引入了垃圾回收机制，使c++程序员最头疼的内存管理的问题迎刃而解，它使得Java程序员在编写程序的时候不再需要考虑内存管理。由于有个垃圾回收机制，Java中的对象不再有"作用域"的概念，只有对象的引用才有"作用域"。垃圾回收可以有效的防止内存泄露，有效的使用可以使用的内存。垃圾回收器通常是作为一个单独的低级别的线程运行，不可预知的情况下对内存堆中已经死亡的或者长时间没有使用的对象进行清楚和回收，程序员不能实时的调用垃圾回收器对某个对象或所有对象进行垃圾回收。回收机制有分代复制垃圾回收和标记垃圾回收，增量垃圾回收。 </p>
		<p>52、请说出你所知道的线程同步的方法。 </p>
		<p>wait():使一个线程处于等待状态，并且释放所持有的对象的lock。 </p>
		<p>sleep():使一个正在运行的线程处于睡眠状态，是一个静态方法，调用此方法要捕捉InterruptedException异常。 </p>
		<p>notify():唤醒一个处于等待状态的线程，注意的是在调用此方法的时候，并不能确切的唤醒某一个等待状态的线程，而是由JVM确定唤醒哪个线程，而且不是按优先级。 </p>
		<p>Allnotity():唤醒所有处入等待状态的线程，注意并不是给所有唤醒线程一个对象的锁，而是让它们竞争。 </p>
		<p>53、你所知道的集合类都有哪些？主要方法？ </p>
		<p>最常用的集合类是 List 和 Map。 List 的具体实现包括 ArrayList 和 Vector，它们是可变大小的列表，比较适合构建、存储和操作任何类型对象的元素列表。 List 适用于按数值索引访问元素的情形。 </p>
		<p>Map 提供了一个更通用的元素存储方法。 Map 集合类用于存储元素对（称作"键"和"值"），其中每个键映射到一个值。 </p>
		<p>54、描述一下JVM加载class文件的原理机制? </p>
		<p>JVM中类的装载是由ClassLoader和它的子类来实现的,Java ClassLoader 是一个重要的Java运行时系统组件。它负责在运行时查找和装入类文件的类。 </p>
		<p>55、char型变量中能不能存贮一个中文汉字?为什么? </p>
		<p>能够定义成为一个中文的，因为java中以unicode编码，一个char占16个字节，所以放一个中文是没问题的 </p>
		<p>56、多线程有几种实现方法,都是什么?同步有几种实现方法,都是什么? </p>
		<p>多线程有两种实现方法，分别是继承Thread类与实现Runnable接口 </p>
		<p>同步的实现方面有两种，分别是synchronized,wait与notify </p>
		<p>57、JSP的内置对象及方法。 </p>
		<p>request表示HttpServletRequest对象。它包含了有关浏览器请求的信息，并且提供了几个用于获取cookie, header, 和session数据的有用的方法。 </p>
		<p>response表示HttpServletResponse对象，并提供了几个用于设置送回 浏览器的响应的方法（如cookies,头信息等） </p>
		<p>out对象是javax.jsp.JspWriter的一个实例，并提供了几个方法使你能用于向浏览器回送输出结果。 </p>
		<p>pageContext表示一个javax.servlet.jsp.PageContext对象。它是用于方便存取各种范围的名字空间、servlet相关的对象的API，并且包装了通用的servlet相关功能的方法。 </p>
		<p>session表示一个请求的javax.servlet.http.HttpSession对象。Session可以存贮用户的状态信息 </p>
		<p>applicaton 表示一个javax.servle.ServletContext对象。这有助于查找有关servlet引擎和servlet环境的信息 </p>
		<p>config表示一个javax.servlet.ServletConfig对象。该对象用于存取servlet实例的初始化参数。 </p>
		<p>page表示从该页面产生的一个servlet实例 </p>
		<p>58、线程的基本概念、线程的基本状态以及状态之间的关系 </p>
		<p>线程指在程序执行过程中，能够执行程序代码的一个执行单位，每个程序至少都有一个线程，也就是程序本身。 </p>
		<p>Java中的线程有四种状态分别是：运行、就绪、挂起、结束。 </p>
		<p>59、JSP的常用指令 </p>
		<p>&lt;<a href="mailto:%@page">%@page</a> language="java" contenType="text/html;charset=gb2312" session="true" buffer="64kb" autoFlush="true" isThreadSafe="true" info="text" errorPage="error.jsp" isErrorPage="true" isELIgnored="true" pageEncoding="gb2312" import="java.sql.*"%&gt; </p>
		<p>isErrorPage(是否能使用Exception对象)，isELIgnored(是否忽略表达式) </p>
		<p>&lt;<a href="mailto:%@include">%@include</a> file="filename"%&gt; </p>
		<p>&lt;<a href="mailto:%@taglib">%@taglib</a> prefix="c"uri="<a href="http://......&quot;%">http://......"%</a>&gt; </p>
		<p>60、什么情况下调用doGet()和doPost()？ </p>
		<p>Jsp页面中的form标签里的method属性为get时调用doGet()，为post时调用doPost()。 </p>
		<p>61、servlet的生命周期 </p>
		<p>web容器加载servlet，生命周期开始。通过调用servlet的init()方法进行servlet的初始化。通过调用service()方法实现，根据请求的不同调用不同的do***()方法。结束服务，web容器调用servlet的destroy()方法。 </p>
		<p>62、如何现实servlet的单线程模式 </p>
		<p>&lt;%@ page isThreadSafe="false"%&gt; </p>
		<p>63、页面间对象传递的方法 </p>
		<p>request，session，application，cookie等 </p>
		<p>64、JSP和Servlet有哪些相同点和不同点，他们之间的联系是什么？ </p>
		<p>JSP是Servlet技术的扩展，本质上是Servlet的简易方式，更强调应用的外表表达。JSP编译后是"类servlet"。Servlet和JSP最主要的不同点在于，Servlet的应用逻辑是在Java文件中，并且完全从表示层中的HTML里分离开来。而JSP的情况是Java和HTML可以组合成一个扩展名为.jsp的文件。JSP侧重于视图，Servlet主要用于控制逻辑。 </p>
		<p>65、四种会话跟踪技术 </p>
		<p>会话作用域ServletsJSP 页面描述 </p>
		<p>page否是代表与一个页面相关的对象和属性。一个页面由一个编译好的 Java servlet 类（可以带有任何的 include 指令，但是没有 include 动作）表示。这既包括 servlet 又包括被编译成 servlet 的 JSP 页面 </p>
		<p>request是是代表与 Web 客户机发出的一个请求相关的对象和属性。一个请求可能跨越多个页面，涉及多个 Web 组件（由于 forward 指令和 include 动作的关系） </p>
		<p>session是是代表与用于某个 Web 客户机的一个用户体验相关的对象和属性。一个 Web 会话可以也经常会跨越多个客户机请求 </p>
		<p>application是是代表与整个 Web 应用程序相关的对象和属性。这实质上是跨越整个 Web 应用程序，包括多个页面、请求和会话的一个全局作用域 </p>
		<p>66、Request对象的主要方法： </p>
		<p>setAttribute(String name,Object)：设置名字为name的request的参数值 </p>
		<p>getAttribute(String name)：返回由name指定的属性值 </p>
		<p>getAttributeNames()：返回request对象所有属性的名字集合，结果是一个枚举的实例 </p>
		<p>getCookies()：返回客户端的所有Cookie对象，结果是一个Cookie数组 </p>
		<p>getCharacterEncoding()：返回请求中的字符编码方式 </p>
		<p>getContentLength()：返回请求的Body的长度 </p>
		<p>getHeader(String name)：获得HTTP协议定义的文件头信息 </p>
		<p>getHeaders(String name)：返回指定名字的request Header的所有值，结果是一个枚举的实例 </p>
		<p>getHeaderNames()：返回所以request Header的名字，结果是一个枚举的实例 </p>
		<p>getInputStream()：返回请求的输入流，用于获得请求中的数据 </p>
		<p>getMethod()：获得客户端向服务器端传送数据的方法 </p>
		<p>getParameter(String name)：获得客户端传送给服务器端的有name指定的参数值 </p>
		<p>getParameterNames()：获得客户端传送给服务器端的所有参数的名字，结果是一个枚举的实例 </p>
		<p>getParameterValues(String name)：获得有name指定的参数的所有值 </p>
		<p>getProtocol()：获取客户端向服务器端传送数据所依据的协议名称 </p>
		<p>getQueryString()：获得查询字符串 </p>
		<p>getRequestURI()：获取发出请求字符串的客户端地址 </p>
		<p>getRemoteAddr()：获取客户端的IP地址 </p>
		<p>getRemoteHost()：获取客户端的名字 </p>
		<p>getSession([Boolean create])：返回和请求相关Session </p>
		<p>getServerName()：获取服务器的名字 </p>
		<p>getServletPath()：获取客户端所请求的脚本文件的路径 </p>
		<p>getServerPort()：获取服务器的端口号 </p>
		<p>removeAttribute(String name)：删除请求中的一个属性 </p>
		<p>67、J2EE是技术还是平台还是框架？ </p>
		<p>J2EE本身是一个标准，一个为企业分布式应用的开发提供的标准平台。 </p>
		<p>J2EE也是一个框架，包括JDBC、JNDI、RMI、JMS、EJB、JTA等技术。 </p>
		<p>68、我们在web应用开发过程中经常遇到输出某种编码的字符，如iso8859-1等，如何输出一个某种编码的字符串？ </p>
		<p>Public String translate (String str) { </p>
		<p>String tempStr = ""; </p>
		<p>try { </p>
		<p>tempStr = new String(str.getBytes("ISO-8859-1"), "GBK"); </p>
		<p>tempStr = tempStr.trim(); </p>
		<p>} </p>
		<p>catch (Exception e) { </p>
		<p>System.err.println(e.getMessage()); </p>
		<p>} </p>
		<p>return tempStr; </p>
		<p>} </p>
		<p>69、简述逻辑操作(&amp;,|,^)与条件操作(&amp;&amp;,||)的区别。 </p>
		<p>区别主要答两点：a.条件操作只能操作布尔型的,而逻辑操作不仅可以操作布尔型,而且可以操作数值型 </p>
		<p>b.逻辑操作不会产生短路 </p>
		<p>70、XML文档定义有几种形式？它们之间有何本质区别？解析XML文档有哪几种方式？ </p>
		<p>a: 两种形式 dtd schema，b: 本质区别:schema本身是xml的，可以被XML解析器解析(这也是从DTD上发展schema的根本目的)，c:有DOM,SAX,STAX等 </p>
		<p>DOM:处理大型文件时其性能下降的非常厉害。这个问题是由DOM的树结构所造成的，这种结构占用的内存较多，而且DOM必须在解析文件之前把整个文档装入内存,适合对XML的随机访问 </p>
		<p>SAX:不现于DOM,SAX是事件驱动型的XML解析方式。它顺序读取XML文件，不需要一次全部装载整个文件。当遇到像文件开头，文档结束，或者标签开头与标签结束时，它会触发一个事件，用户通过在其回调事件中写入处理代码来处理XML文件，适合对XML的顺序访问 </p>
		<p>STAX:Streaming API for XML (StAX) </p>
		<p>71、简述synchronized和java.util.concurrent.locks.Lock的异同 ？ </p>
		<p>主要相同点：Lock能完成synchronized所实现的所有功能 </p>
		<p>主要不同点：Lock有比synchronized更精确的线程语义和更好的性能。synchronized会自动释放锁，而Lock一定要求程序员手工释放，并且必须在finally从句中释放。 </p>
		<p>72、EJB的角色和三个对象 </p>
		<p>一个完整的基于EJB的分布式计算结构由六个角色组成，这六个角色可以由不同的开发商提供，每个角色所作的工作必须遵循Sun公司提供的EJB规范，以保证彼此之间的兼容性。这六个角色分别是EJB组件开发者（Enterprise Bean Provider） 、应用组合者（Application Assembler）、部署者（Deployer）、EJB 服务器提供者（EJB Server Provider）、EJB 容器提供者（EJB Container Provider）、系统管理员（System Administrator） </p>
		<p>三个对象是Remote（Local）接口、Home（LocalHome）接口，Bean类 </p>
		<p>73、EJB容器提供的服务 </p>
		<p>主要提供声明周期管理、代码产生、持续性管理、安全、事务管理、锁和并发行管理等服务。 </p>
		<p>74、EJB规范规定EJB中禁止的操作有哪些？ </p>
		<p>1.不能操作线程和线程API(线程API指非线程对象的方法如notify,wait等)，2.不能操作awt，3.不能实现服务器功能，4.不能对静态属生存取，5.不能使用IO操作直接存取文件系统，6.不能加载本地库.，7.不能将this作为变量和返回，8.不能循环调用。 </p>
		<p>75、remote接口和home接口主要作用 </p>
		<p>remote接口定义了业务方法，用于EJB客户端调用业务方法。 </p>
		<p>home接口是EJB工厂用于创建和移除查找EJB实例 </p>
		<p>76、bean 实例的生命周期 </p>
		<p>对于Stateless Session Bean、Entity Bean、Message Driven Bean一般存在缓冲池管理，而对于Entity Bean和Statefull Session Bean存在Cache管理，通常包含创建实例，设置上下文、创建EJB Object（create）、业务方法调用、remove等过程，对于存在缓冲池管理的Bean，在create之后实例并不从内存清除，而是采用缓冲池调度机制不断重用实例，而对于存在Cache管理的Bean则通过激活和去激活机制保持Bean的状态并限制内存中实例数量。 </p>
		<p>77、EJB的激活机制 </p>
		<p>以Stateful Session Bean 为例：其Cache大小决定了内存中可以同时存在的Bean实例的数量，根据MRU或NRU算法，实例在激活和去激活状态之间迁移，激活机制是当客户端调用某个EJB实例业务方法时，如果对应EJB Object发现自己没有绑定对应的Bean实例则从其去激活Bean存储中（通过序列化机制存储实例）回复（激活）此实例。状态变迁前会调用对应的ejbActive和ejbPassivate方法。 </p>
		<p>78、EJB的几种类型 </p>
		<p>会话（Session）Bean ，实体（Entity）Bean 消息驱动的（Message Driven）Bean </p>
		<p>会话Bean又可分为有状态（Stateful）和无状态（Stateless）两种 </p>
		<p>实体Bean可分为Bean管理的持续性（BMP）和容器管理的持续性（CMP）两种 </p>
		<p>79、客服端调用EJB对象的几个基本步骤 </p>
		<p>设置JNDI服务工厂以及JNDI服务地址系统属性，查找Home接口，从Home接口调用Create方法创建Remote接口，通过Remote接口调用其业务方法。 </p>
		<p>80、如何给weblogic指定大小的内存? </p>
		<p>在启动Weblogic的脚本中（位于所在Domian对应服务器目录下的startServerName），增加set MEM_ARGS=-Xms32m -Xmx200m，可以调整最小内存为32M，最大200M </p>
		<p>81、如何设定的weblogic的热启动模式(开发模式)与产品发布模式? </p>
		<p>可以在管理控制台中修改对应服务器的启动模式为开发或产品模式之一。或者修改服务的启动文件或者commenv文件，增加set PRODUCTION_MODE=true。 </p>
		<p>82、如何启动时不需输入用户名与密码? </p>
		<p>修改服务启动文件，增加 WLS_USER和WLS_PW项。也可以在boot.properties文件中增加加密过的用户名和密码. </p>
		<p>83、在weblogic管理制台中对一个应用域(或者说是一个网站,Domain)进行jms及ejb或连接池等相关信息进行配置后,实际保存在什么文件中? </p>
		<p>保存在此Domain的config.xml文件中，它是服务器的核心配置文件。 </p>
		<p>84、说说weblogic中一个Domain的缺省目录结构?比如要将一个简单的helloWorld.jsp放入何目录下,然的在浏览器上就可打入http://主机:端口号//helloword.jsp就可以看到运行结果了? 又比如这其中用到了一个自己写的javaBean该如何办? </p>
		<p>Domain目录\服务器目录\applications，将应用目录放在此目录下将可以作为应用访问，如果是Web应用，应用目录需要满足Web应用目录要求，jsp文件可以直接放在应用目录中，Javabean需要放在应用目录的WEB-INF目录的classes目录中，设置服务器的缺省应用将可以实现在浏览器上无需输入应用名。 </p>
		<p>85、在weblogic中发布ejb需涉及到哪些配置文件 </p>
		<p>不同类型的EJB涉及的配置文件不同，都涉及到的配置文件包括ejb-jar.xml,weblogic-ejb-jar.xmlCMP实体Bean一般还需要weblogic-cmp-rdbms-jar.xml </p>
		<p>86、如何在weblogic中进行ssl配置与客户端的认证配置或说说j2ee(标准)进行ssl的配置 </p>
		<p>缺省安装中使用DemoIdentity.jks和DemoTrust.jks KeyStore实现SSL，需要配置服务器使用Enable SSL，配置其端口，在产品模式下需要从CA获取私有密钥和数字证书，创建identity和trust keystore，装载获得的密钥和数字证书。可以配置此SSL连接是单向还是双向的。 </p>
		<p>87、如何查看在weblogic中已经发布的EJB? </p>
		<p>可以使用管理控制台，在它的Deployment中可以查看所有已发布的EJB </p>
		<p>88、CORBA是什么?用途是什么? </p>
		<p>CORBA 标准是公共对象请求代理结构(Common Object Request Broker Architecture)，由对象管理组织 (Object Management Group，缩写为 OMG)标准化。它的组成是接口定义语言(IDL), 语言绑定(binding:也译为联编)和允许应用程序间互操作的协议。 其目的为：用不同的程序设计语言书写在不同的进程中运行，为不同的操作系统开发。 </p>
		<p>89、说说你所熟悉或听说过的j2ee中的几种常用模式?及对设计模式的一些看法 </p>
		<p>Session Facade Pattern：使用SessionBean访问EntityBean </p>
		<p>Message Facade Pattern：实现异步调用 </p>
		<p>EJB Command Pattern：使用Command JavaBeans取代SessionBean，实现轻量级访问 </p>
		<p>Data Transfer Object Factory：通过DTO Factory简化EntityBean数据提供特性 </p>
		<p>Generic Attribute Access：通过AttibuteAccess接口简化EntityBean数据提供特性 </p>
		<p>Business Interface：通过远程（本地）接口和Bean类实现相同接口规范业务逻辑一致性 </p>
		<p>ＥＪＢ架构的设计好坏将直接影响系统的性能、可扩展性、可维护性、组件可重用性及开发效率。项目越复杂，项目队伍越庞大则越能体现良好设计的重要性。 </p>
		<p>90、说说在weblogic中开发消息Bean时的persistent与non-persisten的差别 </p>
		<p>persistent方式的MDB可以保证消息传递的可靠性,也就是如果EJB容器出现问题而JMS服务器依然会将消息在此MDB可用的时候发送过来，而non－persistent方式的消息将被丢弃。 </p>
		<p>91、Servlet执行时一般实现哪几个方法？ </p>
		<p>public void init(ServletConfig config) </p>
		<p>public ServletConfig getServletConfig() </p>
		<p>public String getServletInfo() </p>
		<p>public void service(ServletRequest request,ServletResponse response) </p>
		<p>public void destroy() </p>
		<p>92、j2ee常用的设计模式？说明工厂模式。 </p>
		<p>Java中的23种设计模式： </p>
		<p>Factory（工厂模式）， Builder（建造模式）， Factory Method（工厂方法模式）， </p>
		<p>Prototype（原始模型模式），Singleton（单例模式）， Facade（门面模式）， </p>
		<p>Adapter（适配器模式）， Bridge（桥梁模式）， Composite（合成模式）， </p>
		<p>Decorator（装饰模式）， Flyweight（享元模式）， Proxy（代理模式）， </p>
		<p>Command（命令模式）， Interpreter（解释器模式）， Visitor（访问者模式）， </p>
		<p>Iterator（迭代子模式）， Mediator（调停者模式）， Memento（备忘录模式）， </p>
		<p>Observer（观察者模式）， State（状态模式）， Strategy（策略模式）， </p>
		<p>Template Method（模板方法模式）， Chain Of Responsibleity（责任链模式） </p>
		<p>工厂模式：工厂模式是一种经常被使用到的模式，根据工厂模式实现的类可以根据提供的数据生成一组类中某一个类的实例，通常这一组类有一个公共的抽象父类并且实现了相同的方法，但是这些方法针对不同的数据进行了不同的操作。首先需要定义一个基类，该类的子类通过不同的方法实现了基类中的方法。然后需要定义一个工厂类，工厂类可以根据条件生成不同的子类实例。当得到子类的实例后，开发人员可以调用基类中的方法而不必考虑到底返回的是哪一个子类的实例。 </p>
		<p>93、EJB需直接实现它的业务接口或Home接口吗，请简述理由。 </p>
		<p>远程接口和Home接口不需要直接实现，他们的实现代码是由服务器产生的，程序运行中对应实现类会作为对应接口类型的实例被使用。 </p>
		<p>94、排序都有哪几种方法？请列举。用JAVA实现一个快速排序。 </p>
		<p>排序的方法有：插入排序（直接插入排序、希尔排序），交换排序（冒泡排序、快速排序），选择排序（直接选择排序、堆排序），归并排序，分配排序（箱排序、基数排序） </p>
		<p>快速排序的伪代码。 </p>
		<p>/ /使用快速排序方法对a[ 0 :n- 1 ]排序 </p>
		<p>从a[ 0 :n- 1 ]中选择一个元素作为m i d d l e，该元素为支点 </p>
		<p>把余下的元素分割为两段left 和r i g h t，使得l e f t中的元素都小于等于支点，而right 中的元素都大于等于支点 </p>
		<p>递归地使用快速排序方法对left 进行排序 </p>
		<p>递归地使用快速排序方法对right 进行排序 </p>
		<p>所得结果为l e f t + m i d d l e + r i g h t </p>
		<p>95、请对以下在J2EE中常用的名词进行解释(或简单描述) </p>
		<p>web容器：给处于其中的应用程序组件（JSP，SERVLET）提供一个环境，使JSP,SERVLET直接更容器中的环境变量接口交互，不必关注其它系统问题。主要有WEB服务器来实现。例如：TOMCAT,WEBLOGIC,WEBSPHERE等。该容器提供的接口严格遵守J2EE规范中的WEB APPLICATION 标准。我们把遵守以上标准的WEB服务器就叫做J2EE中的WEB容器。 </p>
		<p>EJB容器：Enterprise java bean 容器。更具有行业领域特色。他提供给运行在其中的组件EJB各种管理功能。只要满足J2EE规范的EJB放入该容器，马上就会被容器进行高效率的管理。并且可以通过现成的接口来获得系统级别的服务。例如邮件服务、事务管理。 </p>
		<p>JNDI：（Java Naming &amp; Directory Interface）JAVA命名目录服务。主要提供的功能是：提供一个目录系统，让其它各地的应用程序在其上面留下自己的索引，从而满足快速查找和定位分布式应用程序的功能。 </p>
		<p>JMS：（Java Message Service）JAVA消息服务。主要实现各个应用程序之间的通讯。包括点对点和广播。 </p>
		<p>JTA：（Java Transaction API）JAVA事务服务。提供各种分布式事务服务。应用程序只需调用其提供的接口即可。 </p>
		<p>JAF：（Java Action FrameWork）JAVA安全认证框架。提供一些安全控制方面的框架。让开发者通过各种部署和自定义实现自己的个性安全控制策略。 </p>
		<p>RMI/IIOP:（Remote Method Invocation /internet对象请求中介协议）他们主要用于通过远程调用服务。例如，远程有一台计算机上运行一个程序，它提供股票分析服务，我们可以在本地计算机上实现对其直接调用。当然这是要通过一定的规范才能在异构的系统之间进行通信。RMI是JAVA特有的。 </p>
		<p>96、JAVA语言如何进行异常处理，关键字：throws,throw,try,catch,finally分别代表什么意义？在try块中可以抛出异常吗？ </p>
		<p>Java通过面向对象的方法进行异常处理，把各种不同的异常进行分类，并提供了良好的接口。在Java中，每个异常都是一个对象，它是Throwable类或其它子类的实例。当一个方法出现异常后便抛出一个异常对象，该对象中包含有异常信息，调用这个对象的方法可以捕获到这个异常并进行处理。Java的异常处理是通过5个关键词来实现的：try、catch、throw、throws和finally。一般情况下是用try来执行一段程序，如果出现异常，系统会抛出（throws）一个异常，这时候你可以通过它的类型来捕捉（catch）它，或最后（finally）由缺省处理器来处理。 </p>
		<p>用try来指定一块预防所有"异常"的程序。紧跟在try程序后面，应包含一个catch子句来指定你想要捕捉的"异常"的类型。 </p>
		<p>throw语句用来明确地抛出一个"异常"。 </p>
		<p>throws用来标明一个成员函数可能抛出的各种"异常"。 </p>
		<p>Finally为确保一段代码不管发生什么"异常"都被执行一段代码。 </p>
		<p>可以在一个成员函数调用的外面写一个try语句，在这个成员函数内部写另一个try语句保护其他代码。每当遇到一个try语句，"异常"的框架就放到堆栈上面，直到所有的try语句都完成。如果下一级的try语句没有对某种"异常"进行处理，堆栈就会展开，直到遇到有处理这种"异常"的try语句。 </p>
		<p>97、一个".java"源文件中是否可以包括多个类（不是内部类）？有什么限制？ </p>
		<p>可以。必须只有一个类名与文件名相同。 </p>
		<p>98、MVC的各个部分都有那些技术来实现?如何实现? </p>
		<p>MVC是Model－View－Controller的简写。"Model" 代表的是应用的业务逻辑（通过JavaBean，EJB组件实现）， "View" 是应用的表示面（由JSP页面产生），"Controller" 是提供应用的处理过程控制（一般是一个Servlet），通过这种设计模型把应用逻辑，处理过程和显示逻辑分成不同的组件实现。这些组件可以进行交互和重用。 </p>
		<p>99、java中有几种方法可以实现一个线程？用什么关键字修饰同步方法? stop()和suspend()方法为何不推荐使用？ </p>
		<p>有两种实现方法，分别是继承Thread类与实现Runnable接口 </p>
		<p>用synchronized关键字修饰同步方法 </p>
		<p>反对使用stop()，是因为它不安全。它会解除由线程获取的所有锁定，而且如果对象处于一种不连贯状态，那么其他线程能在那种状态下检查和修改它们。结果很难检查出真正的问题所在。suspend()方法容易发生死锁。调用suspend()的时候，目标线程会停下来，但却仍然持有在这之前获得的锁定。此时，其他任何线程都不能访问锁定的资源，除非被"挂起"的线程恢复运行。对任何线程来说，如果它们想恢复目标线程，同时又试图使用任何一个锁定的资源，就会造成死锁。所以不应该使用suspend()，而应在自己的Thread类中置入一个标志，指出线程应该活动还是挂起。若标志指出线程应该挂起，便用wait()命其进入等待状态。若标志指出线程应当恢复，则用一个notify()重新启动线程。 </p>
		<p>100、java中有几种类型的流？JDK为每种类型的流提供了一些抽象类以供继承，请说出他们分别是哪些类？ </p>
		<p>字节流，字符流。字节流继承于InputStream \ OutputStream，字符流继承于InputStreamReader \ OutputStreamWriter。在java.io包中还有许多其他的流，主要是为了提高性能和使用方便。 </p>
		<p>101、java中会存在内存泄漏吗，请简单描述。 </p>
		<p>会。如：int i,i2; return (i-i2); //when i为足够大的正数,i2为足够大的负数。结果会造成溢位，导致错误。 </p>
		<p>102、java中实现多态的机制是什么？ </p>
		<p>方法的重写Overriding和重载Overloading是Java多态性的不同表现。重写Overriding是父类与子类之间多态性的一种表现，重载Overloading是一个类中多态性的一种表现。 </p>
		<p>103、垃圾回收器的基本原理是什么？垃圾回收器可以马上回收内存吗？有什么办法主动通知虚拟机进行垃圾回收？ </p>
		<p>对于GC来说，当程序员创建对象时，GC就开始监控这个对象的地址、大小以及使用情况。通常，GC采用有向图的方式记录和管理堆(heap)中的所有对象。通过这种方式确定哪些对象是"可达的"，哪些对象是"不可达的"。当GC确定一些对象为"不可达"时，GC就有责任回收这些内存空间。可以。程序员可以手动执行System.gc()，通知GC运行，但是Java语言规范并不保证GC一定会执行。 </p>
		<p>104、静态变量和实例变量的区别？ </p>
		<p>static i = 10; //常量 </p>
		<p>class A a; a.i =10;//可变 </p>
		<p>105、什么是java序列化，如何实现java序列化？ </p>
		<p>序列化就是一种用来处理对象流的机制，所谓对象流也就是将对象的内容进行流化。可以对流化后的对象进行读写操作，也可将流化后的对象传输于网络之间。序列化是为了解决在对对象流进行读写操作时所引发的问题。 </p>
		<p>序列化的实现：将需要被序列化的类实现Serializable接口，该接口没有需要实现的方法，implements Serializable只是为了标注该对象是可被序列化的，然后使用一个输出流(如：FileOutputStream)来构造一个ObjectOutputStream(对象流)对象，接着，使用ObjectOutputStream对象的writeObject(Object obj)方法就可以将参数为obj的对象写出(即保存其状态)，要恢复的话则用输入流。 </p>
		<p>106、是否可以从一个static方法内部发出对非static方法的调用？ </p>
		<p>不可以,如果其中包含对象的method()；不能保证对象初始化. </p>
		<p>107、写clone()方法时，通常都有一行代码，是什么？ </p>
		<p>Clone 有缺省行为，super.clone();他负责产生正确大小的空间，并逐位复制。 </p>
		<p>108、在JAVA中，如何跳出当前的多重嵌套循环？ </p>
		<p>用break; return 方法。 </p>
		<p>109、List、Map、Set三个接口，存取元素时，各有什么特点？ </p>
		<p>List 以特定次序来持有元素，可有重复元素。Set 无法拥有重复元素,内部排序。Map 保存key-value值，value可多值。 </p>
		<p>110、J2EE是什么？ </p>
		<p>J2EE是Sun公司提出的多层(multi-diered),分布式(distributed),基于组件(component-base)的企业级应用模型(enterpriese application model).在这样的一个应用系统中，可按照功能划分为不同的组件，这些组件又可在不同计算机上，并且处于相应的层次(tier)中。所属层次包括客户层(clietn tier)组件,web层和组件,Business层和组件,企业信息系统(EIS)层。 </p>
		<p>111、UML方面 </p>
		<p>标准建模语言UML。用例图,静态图(包括类图、对象图和包图),行为图,交互图(顺序图,合作图),实现图。 </p>
		<p>112、说出一些常用的类，包，接口，请各举5个 </p>
		<p>常用的类：BufferedReader BufferedWriter FileReader FileWirter String Integer </p>
		<p>常用的包：java.lang java.awt java.io java.util java.sql </p>
		<p>常用的接口：Remote List Map Document NodeList </p>
		<p>113、开发中都用到了那些设计模式?用在什么场合? </p>
		<p>每个模式都描述了一个在我们的环境中不断出现的问题，然后描述了该问题的解决方案的核心。通过这种方式，你可以无数次地使用那些已有的解决方案，无需在重复相同的工作。主要用到了MVC的设计模式。用来开发JSP/Servlet或者J2EE的相关应用。简单工厂模式等。 </p>
		<p>114、jsp有哪些动作?作用分别是什么? </p>
		<p>    JSP共有以下6种基本动作 jsp:include：在页面被请求的时候引入一个文件。     jsp:useBean：寻找或者实例化一个JavaBean。 jsp:setProperty：设置JavaBean的属性。 jsp:getProperty：输出某个JavaBean的属性。 jsp:forward：把请求转到一个新的页面。 jsp:plugin：根据浏览器类型为Java插件生成OBJECT或EMBED标记。 </p>
		<p>115、Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类，是否可以implements(实现)interface(接口)? </p>
		<p>    可以继承其他类或完成其他接口，在swing编程中常用此方式。 </p>
		<p>116、应用服务器与WEB SERVER的区别？ </p>
		<p>    应用服务器：Weblogic、Tomcat、Jboss </p>
		<p>    WEB SERVER：IIS、 Apache </p>
		<p>117、BS与CS的联系与区别。 </p>
		<p>    C/S是Client/Server的缩写。服务器通常采用高性能的PC、工作站或小型机，并采用大型数据库系统，如Oracle、Sybase、Informix或 SQL Server。客户端需要安装专用的客户端软件。 </p>
		<p>    B/Ｓ是Brower/Server的缩写，客户机上只要安装一个浏览器（Browser），如Netscape Navigator或Internet Explorer，服务器安装Oracle、Sybase、Informix或 SQL Server等数据库。在这种结构下，用户界面完全通过WWW浏览器实现，一部分事务逻辑在前端实现，但是主要事务逻辑在服务器端实现。浏览器通过Ｗeb Server 同数据库进行数据交互。 </p>
		<p>C/S 与 B/S 区别： </p>
		<p>１．硬件环境不同: </p>
		<p>    C/S 一般建立在专用的网络上, 小范围里的网络环境, 局域网之间再通过专门服务器提供连接和数据交换服务. </p>
		<p>    B/S 建立在广域网之上的, 不必是专门的网络硬件环境,例与电话上网, 租用设备. 信息自己管理. 有比C/S更强的适应范围, 一般只要有操作系统和浏览器就行 </p>
		<p>２．对安全要求不同 </p>
		<p>    C/S 一般面向相对固定的用户群, 对信息安全的控制能力很强. 一般高度机密的信息系统采用C/S 结构适宜. 可以通过B/S发布部分可公开信息. </p>
		<p>    B/S 建立在广域网之上, 对安全的控制能力相对弱, 可能面向不可知的用户。 </p>
		<p>３．对程序架构不同 </p>
		<p>    C/S 程序可以更加注重流程, 可以对权限多层次校验, 对系统运行速度可以较少考虑. </p>
		<p>    B/S 对安全以及访问速度的多重的考虑, 建立在需要更加优化的基础之上. 比C/S有更高的要求 B/S结构的程序架构是发展的趋势, 从MS的.Net系列的BizTalk 2000 Exchange 2000等, 全面支持网络的构件搭建的系统. SUN 和IBM推的JavaBean 构件技术等,使 B/S更加成熟. </p>
		<p>４．软件重用不同 </p>
		<p>    C/S 程序可以不可避免的整体性考虑, 构件的重用性不如在B/S要求下的构件的重用性好. </p>
		<p>    B/S 对的多重结构,要求构件相对独立的功能. 能够相对较好的重用.就入买来的餐桌可以再利用,而不是做在墙上的石头桌子 </p>
		<p>５．系统维护不同 </p>
		<p>    C/S 程序由于整体性, 必须整体考察, 处理出现的问题以及系统升级. 升级难. 可能是再做一个全新的系统 </p>
		<p>    B/S 构件组成,方面构件个别的更换,实现系统的无缝升级. 系统维护开销减到最小.用户从网上自己下载安装就可以实现升级. </p>
		<p>６．处理问题不同 </p>
		<p>    C/S 程序可以处理用户面固定, 并且在相同区域, 安全要求高需求, 与操作系统相关. 应该都是相同的系统 </p>
		<p>    B/S 建立在广域网上, 面向不同的用户群, 分散地域, 这是C/S无法作到的. 与操作系统平台关系最小. </p>
		<p>７．用户接口不同 </p>
		<p>    C/S 多是建立的Window平台上,表现方法有限,对程序员普遍要求较高 </p>
		<p>    B/S 建立在浏览器上, 有更加丰富和生动的表现方式与用户交流. 并且大部分难度减低,减低开发成本. </p>
		<p>８．信息流不同 </p>
		<p>    C/S 程序一般是典型的中央集权的机械式处理, 交互性相对低 </p>
		<p>    B/S 信息流向可变化, B-B B-C B-G等信息、流向的变化, 更像交易中心。 </p>
		<p>118、LINUX下线程，GDI类的解释。 </p>
		<p>    LINUX实现的就是基于核心轻量级进程的"一对一"线程模型，一个线程实体对应一个核心轻量级进程，而线程之间的管理在核外函数库中实现。 </p>
		<p>    GDI类为图像设备编程接口类库。 </p>
		<p>119、STRUTS的应用(如STRUTS架构) </p>
		<p>    Struts是采用Java Servlet/JavaServer Pages技术，开发Web应用程序的开放源码的framework。 采用Struts能开发出基于MVC(Model-View-Controller)设计模式的应用构架。 Struts有如下的主要功能： 一.包含一个controller servlet，能将用户的请求发送到相应的Action对象。 二.JSP自由tag库，并且在controller servlet中提供关联支持，帮助开发员创建交互式表单应用。 三.提供了一系列实用对象：XML处理、通过Java reflection APIs自动处理JavaBeans属性、国际化的提示和消息。 </p>
		<p>120、Jdo是什么? </p>
		<p>    JDO是Java对象持久化的新的规范，为java data object的简称,也是一个用于存取某种数据仓库中的对象的标准化API。JDO提供了透明的对象存储，因此对开发人员来说，存储数据对象完全不需要额外的代码（如JDBC API的使用）。这些繁琐的例行工作已经转移到JDO产品提供商身上，使开发人员解脱出来，从而集中时间和精力在业务逻辑上。另外，JDO很灵活，因为它可以在任何数据底层上运行。JDBC只是面向关系数据库（RDBMS）JDO更通用，提供到任何数据底层的存储功能，比如关系数据库、文件、XML以及对象数据库（ODBMS）等等，使得应用可移植性更强。 </p>
		<p>121、内部类可以引用他包含类的成员吗？有没有什么限制？ </p>
		<p>    一个内部类对象可以访问创建它的外部类对象的内容 </p>
		<p>122、WEB SERVICE名词解释。JSWDL开发包的介绍。JAXP、JAXM的解释。SOAP、UDDI,WSDL解释。 </p>
		<p>    Web ServiceWeb Service是基于网络的、分布式的模块化组件，它执行特定的任务，遵守具体的技术规范，这些规范使得Web Service能与其他兼容的组件进行互操作。 </p>
		<p>    JAXP(Java API for XML Parsing) 定义了在Java中使用DOM, SAX, XSLT的通用的接口。这样在你的程序中你只要使用这些通用的接口，当你需要改变具体的实现时候也不需要修改代码。 </p>
		<p>JAXM(Java API for XML Messaging) 是为SOAP通信提供访问方法和传输机制的API。 </p>
		<p>    WSDL是一种 XML 格式，用于将网络服务描述为一组端点，这些端点对包含面向文档信息或面向过程信息的消息进行操作。这种格式首先对操作和消息进行抽象描述，然后将其绑定到具体的网络协议和消息格式上以定义端点。相关的具体端点即组合成为抽象端点（服务）。 </p>
		<p>    SOAP即简单对象访问协议(Simple Object Access Protocol)，它是用于交换XML编码信息的轻量级协议。 </p>
		<p>    UDDI 的目的是为电子商务建立标准；UDDI是一套基于Web的、分布式的、为Web Service提供的、信息注册中心的实现标准规范，同时也包含一组使企业能将自身提供的Web Service注册，以使别的企业能够发现的访问协议的实现标准。</p>
<img src ="http://www.blogjava.net/bily/aggbug/81478.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 11:27 <a href="http://www.blogjava.net/bily/articles/81478.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java面试题集（一）</title><link>http://www.blogjava.net/bily/articles/81475.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 03:22:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81475.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81475.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81475.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81475.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81475.html</trackback:ping><description><![CDATA[
		<p>1: 运行时异常与一般异常有何异同？<br /><br />    异常表示程序运行过程中可能出现的非正常状态，运行时异常表示虚拟机的通常操作中可能遇到的异常，是一种常见运行错误。java编译器要求方法必须声明抛出可能发生的非运行时异常，但是并不要求必须声明抛出未被捕获的运行时异常。</p>
		<p>2: 说出ArrayList,Vector, LinkedList的存储性能和特性<br /><br />    ArrayList和Vector都是使用数组方式存储数据，此数组元素数大于实际存储的数据以便增加和插入元素，它们都允许直接按序号索引元素，但是插入元素要涉及数组元素移动等内存操作，所以索引数据快而插入数据慢，Vector由于使用了synchronized方法（线程安全），通常性能上较ArrayList差，而LinkedList使用双向链表实现存储，按序号索引数据需要进行前向或后向遍历，但是插入数据时只需要记录本项的前后项即可，所以插入速度较快。</p>
		<p>3: try {}里有一个return语句，那么紧跟在这个try后的finally {}里的code会不会被执行，什么时候被执行，在return前还是后?<br /><br />   会执行，在return前执行。</p>
		<p>4: 两个对象值相同(x.equals(y) == true)，但却可有不同的hash code，这句话对不对?<br /><br />    不对，有相同的hash code。因为覆盖equals()方法的时候,必须覆盖hashcode()方法,这样才起作用,所以如果两个对象equals的话,那它的hashcode也一定相等.</p>
		<p>5: JAVA语言如何进行异常处理，关键字：throws,throw,try,catch,finally分别代表什么意义？在try块中可以抛出异常吗？<br /><br />    Java通过面向对象的方法进行异常处理，把各种不同的异常进行分类，并提供了良好的接口。在Java中，每个异常都是一个对象，它是Throwable类或其它子类的实例。当一个方法出现异常后便抛出一个异常对象，该对象中包含有异常信息，调用这个对象的方法可以捕获到这个异常并进行处理。Java的异常处理是通过5个关键词来实现的：try、catch、throw、throws和finally。一般情况下是用try来执行一段程序，如果出现异常，系统会抛出（throws）一个异常，这时候你可以通过它的类型来捕捉（catch）它，或最后（finally）由缺省处理器来处理。<br />    用try来指定一块预防所有"异常"的程序。紧跟在try程序后面，应包含一个catch子句来指定你想要捕捉的"异常"的类型。<br />    throw语句用来明确地抛出一个"异常"。<br />    throws用来标明一个成员函数可能抛出的各种"异常"。<br />    Finally为确保一段代码不管发生什么"异常"都被执行一段代码。<br />    可以在一个成员函数调用的外面写一个try语句，在这个成员函数内部写另一个try语句保护其他代码。每当遇到一个try语句，"异常"的框架就放到堆栈上面，直到所有的try语句都完成。如果下一级的try语句没有对某种"异常"进行处理，堆栈就会展开，直到遇到有处理这种"异常"的try语句</p>
		<p> 6:改错<br /><br />class Something {<br />          final int i;<br />          public void doSomething() {<br />               System.out.println("i = " + i);<br />       }<br />}<br />    答案: 错。final int i是个final的instant variable (实例变量，或叫成员变量)。final的instant variable没有default value，必须在constructor (构造器)结束之前被赋予一个明确的值。可以修改为"final int i = 0;"。(注意:与实例变量不一样,实例变量会初始化赋初值)</p>
		<p>7:<br /><br />interface  A{<br />   int x = 0;<br />}<br />class B{<br />   int x =1;<br />}<br />class C extends B implements A {<br />   public void pX(){<br />      System.out.println(x);<br />   }<br />   public static void main(String[] args) {<br />      new C().pX();<br />   }<br />}<br />    答案：错误。在编译时会发生错误(错误描述不同的JVM有不同的信息，意思就是未明确的x调用，两个x都匹配（就象在同时import java.util和java.sql两个包时直接声明Date一样）。对于父类的变量,可以用super.x来明确，而接口的属性默认隐含为 public static final.所以可以通过A.x来明确。</p>
		<p>8: java中实现多态的机制是什么？<br /><br />    方法的重写Overriding和重载Overloading是Java多态性的不同表现。重写Overriding是父类与子类之间多态性的一种表现，重载Overloading是一个类中多态性的一种表现。</p>
		<p>9: 垃圾回收器的基本原理是什么？垃圾回收器可以马上回收内存吗？有什么办法主动通知虚拟机进行垃圾回收？<br /><br />    对于GC来说，当程序员创建对象时，GC就开始监控这个对象的地址、大小以及使用情况。通常，GC采用有向图的方式记录和管理堆(heap)中的所有对象。通过这种方式确定哪些对象是"可达的"，哪些对象是"不可达的"。当GC确定一些对象为"不可达"时，GC就有责任回收这些内存空间。可以。程序员可以手动执行System.gc()，通知GC运行，但是Java语言规范并不保证GC一定会执行。</p>
		<p>10: 静态变量和实例变量的区别？<br /><br />    静态变量是常量,是不可变的.实例变量是可变的.<br />    static i = 10; //常量<br />    class A a;  a.i =10;//可变</p>
		<p>11: 什么是java序列化，如何实现java序列化？<br /><br />    序列化就是一种用来处理对象流的机制，所谓对象流也就是将对象的内容进行流化。可以对流化后的对象进行读写操作，也可将流化后的对象传输于网络之间。序列化是为了解决在对对象流进行读写操作时所引发的问题。<br />    序列化的实现：将需要被序列化的类实现Serializable接口，该接口没有需要实现的方法，implements Serializable只是为了标注该对象是可被序列化的，然后使用一个输出流(如：FileOutputStream)来构造一个ObjectOutputStream(对象流)对象，接着，使用ObjectOutputStream对象的writeObject(Object obj)方法就可以将参数为obj的对象写出(即保存其状态)，要恢复的话则用输入流</p>
		<p>12 : 简述逻辑操作(&amp;,|,^)与条件操作(&amp;&amp;,||)的区别。<br /><br />    区别主要答两点：a.条件操作只能操作布尔型的,而逻辑操作不仅可以操作布尔型,而且可以操作数值型；b.逻辑操作不会产生短路</p>
		<p>13: String s = new String("xyz");创建了几个String Object? <br /><br />    两个,在new String(“xyz”)的时候,在堆中为xyz,分配了一块内存空间,然后将xyz在堆中复制一份,然后再让s指向它.记住,String是很特殊的一个类,它不是什么基本类型.</p>
		<p>14: abstract的method是否可同时是static,是否可同时是native，是否可同时是synchronized?<br /><br />    都不能.</p>
		<p>
				<strong>J2EE部分</strong>
		</p>
		<p>1:J2EE专有名词解释:</p>
		<p>    web容器：给处于其中的应用程序组件（JSP，SERVLET）提供一个环境，使JSP,SERVLET直接更容器中的环境变量接口交互，不必关注其它系统问题。主要有WEB服务器来实现。例如：TOMCAT,WEBLOGIC,WEBSPHERE等。该容器提供的接口严格遵守J2EE规范中的WEB APPLICATION 标准。我们把遵守以上标准的WEB服务器就叫做J2EE中的WEB容器;</p>
		<p>    EJB容器：Enterprise java bean 容器。更具有行业领域特色。他提供给运行在其中的组件    EJB各种管理功能。只要满足J2EE规范的EJB放入该容器，马上就会被容器进行高效率的管理。并且可以通过现成的接口来获得系统级别的服务。例如邮件服务、事务管理。</p>
		<p>    JNDI：（Java Naming &amp; Directory Interface）JAVA命名目录服务。主要提供的功能是：提供一个目录系统，让其它各地的应用程序在其上面留下自己的索引，从而满足快速查找和定位分布式应用程序的功能。<br /><br />    JMS：（Java Message Service）JAVA消息服务。主要实现各个应用程序之间的通讯。包括点对点和广播。<br /><br />    JTA：（Java Transaction API）JAVA事务服务。提供各种分布式事务服务。应用程序只需调用其提供的接口即可。<br /><br />    JAF：（Java Action FrameWork）JAVA安全认证框架。提供一些安全控制方面的框架。让开发者通过各种部署和自定义实现自己的个性安全控制策略。<br /><br />    RMI/IIOP:（Remote Method Invocation /internet对象请求中介协议）他们主要用于通过远程调用服务。例如，远程有一台计算机上运行一个程序，它提供股票分析服务，我们可以在本地计算机上实现对其直接调用。当然这是要通过一定的规范才能在异构的系统之间进行通信。RMI是JAVA特有的。</p>
		<p>    RMI只能是java与java之间互相调用,RMI/IIOP是多语言之间互相调用,因为是借与CORBAR的技术开发的.</p>
		<p>2: 开发中都用到了什么模式:<br /><br />       每个模式都描述了一个在我们的环境中不断出现的问题，然后描述了该问题的解决方案的核心。通过这种方式，你可以无数次地使用那些已有的解决方案，无需在重复相同的工作。在我们的项目中:主要用到了MVC的设计模式。用来开发JSP/Servlet或者J2EE的相关应用,和简单工厂模式等。</p>
		<p>3:jsp有哪些动作?作用分别是什么? <br /><br />    JSP共有以下6种基本动作 jsp:include：在页面被请求的时候引入一个文件。<br />    jsp:useBean：寻找或者实例化一个JavaBean。 jsp:setProperty：设置JavaBean的属性。<br />    jsp:getProperty：输出某个JavaBean的属性。 jsp:forward：把请求转到一个新的页面。<br />    jsp:plugin：根据浏览器类型为Java插件生成OBJECT或EMBED标记。</p>
		<p>4: 说出Servlet的生命周期，并说出Servlet和CGI的区别。</p>
		<p>    当容器启动的时候,web容器加载servlet，生命周期开始。通过调用servlet的init()方法进行servlet的初始化。通过调用service()方法实现，根据请求的不同调用不同的do***()方法。结束服务，web容器调用servlet的destroy()方法。</p>
		<p>    与cgi的区别在于servlet处于服务器进程中，它通过多线程方式运行其service方法，一个实例可以服务于多个请求，并且其实例一般不会销毁，而CGI对每个请求都产生新的进程，服务完成后就销毁，所以效率上低于servlet。</p>
		<p>5:说一下jsp和servlet有什么不同.</p>
		<p>    JSP是Servlet技术的扩展，本质上是Servlet的简易方式，更强调应用的外表表达。JSP编译后是"类servlet"。Servlet和JSP最主要的不同点在于，Servlet的应用逻辑是在Java文件中，并且完全从表示层中的HTML里分离开来。而JSP的情况是Java和HTML可以组合成一个扩展名为.jsp的文件。JSP侧重于视图，Servlet主要用于控制逻辑。</p>
		<p>6: 说一下四种会话作用域</p>
		<p>    Page:是代表与一个页面相关的对象和属性。一个页面由一个编译好的 Java servlet 类（可以带有任何的 include 指令，但是没有 include 动作）表示。(该作用域只在当前页面)</p>
		<p>    Request:是是代表与 Web 客户机发出的一个请求相关的对象和属性。一个请求可能跨越多个页面，涉及多个 Web 组件. 记住,如果用response.sendredirect(“XX.jsp”)将和请求断开了.</p>
		<p>    session是是代表与用于某个 Web 客户机的一个用户体验相关的对象和属性。一个 Web 会话可以也经常会跨越多个客户机请求.session想对request来说作用域范围更大,它不局限与请求,只要IE不关,那它就就一直能在IE中拿到set进去的值.</p>
		<p>    application是是代表与整个 Web 应用程序相关的对象和属性。这实质上是跨越整个 Web 应用程序，包括多个页面、请求和会话的一个全局作用域.和Session的区别是,如果关闭IE了,Session就没有了,而Application依然存在.</p>
		<p>7: J2EE是技术还是平台还是框架？</p>
		<p>    J2EE本身是一个标准，一个为企业分布式应用的开发提供的标准平台。<br />    J2EE也是一个框架，包括JDBC、JNDI、RMI、JMS、EJB、JTA等技术。</p>
		<p>8: XML文档定义有几种形式？它们之间有何本质区别？解析XML文档有哪几种方式？ </p>
		<p>    a: 两种形式 dtd 和 schema，b: 本质区别:schema本身是xml的，可以被XML解析器解析(这也是从DTD上发展schema的根本目的)，c:有DOM,SAX,STAX等 </p>
		<p>     DOM:处理大型文件时其性能下降的非常厉害。这个问题是由DOM的树结构所造成的，这种结构占用的内存较多，而且DOM必须在解析文件之前把整个文档装入内存,适合对XML的随机访问</p>
		<p>    SAX:不现于DOM,SAX是事件驱动型的XML解析方式。它顺序读取XML文件，不需要一次全部装载整个文件。当遇到像文件开头，文档结束，或者标签开头与标签结束时，它会触发一个事件，用户通过在其回调事件中写入处理代码来处理XML文件，适合对XML的顺序访问 </p>
		<p>     STAX:Streaming API for XML (StAX)</p>
		<p>9: 应用服务器有那些？</p>
		<p>    BEA WebLogic Server，IBM WebSphere Application Server，Oracle9i Application Server，jBoss，Tomcat</p>
		<p>10: 会话Bean和实体Bean的区别:</p>
		<p>    会话Bean和实体Bean之间一个主要区别就是他么的存活周期.相对来说,会话Bean的生存周期短.</p>
		<p>    因为会话Bean主要是负责逻辑操作的,每次逻辑操作完之后,会话Bean的功能也就完成了,E应用服务器就有可能将这个对象销毁.而实体Bean是持久性对象,实体Bean肯可能是某一持久性存储器,如数据库的一部分.实体Bean可以通过从数据库获取数据来在内存中创建,他么可以长时间的存在.<br /><br />    注意,会话Bean可以对数据库进行操作,但本身不是持久性对象!因此会话Bean的生命周期不会很长.</p>
		<p>11: 不同Bean之间的管理.</p>
		<p>    对于Stateless Session Bean、Entity Bean、Message Driven Bean一般存在缓冲池管理，而对于Entity Bean和Statefull Session Bean存在Cache管理，通常包含创建实例，设置上下文、创建EJB Object（create）、业务方法调用、remove等过程，对于存在缓冲池管理的Bean，在create之后实例并不从内存清除，而是采用缓冲池调度机制不断重用实例，而对于存在Cache管理的Bean则通过激活和去激活机制保持Bean的状态并限制内存中实例数量。</p>
		<p>12: EJB的激活机制</p>
		<p>    以Stateful Session Bean 为例：其Cache大小决定了内存中可以同时存在的Bean实例的数量，根据MRU或NRU算法，实例在激活和去激活状态之间迁移，激活机制是当客户端调用某个EJB实例业务方法时，如果对应EJB Object发现自己没有绑定对应的Bean实例则从其去激活Bean存储中（通过序列化机制存储实例）回复（激活）此实例。状态变迁前会调用对应的ejbActive和ejbPassivate方法。</p>
		<p>13:熟悉各种Bean的生命周期.</p>
<img src ="http://www.blogjava.net/bily/aggbug/81475.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 11:22 <a href="http://www.blogjava.net/bily/articles/81475.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java笔试题目（一）</title><link>http://www.blogjava.net/bily/articles/81471.html</link><dc:creator>礼必风</dc:creator><author>礼必风</author><pubDate>Thu, 16 Nov 2006 03:10:00 GMT</pubDate><guid>http://www.blogjava.net/bily/articles/81471.html</guid><wfw:comment>http://www.blogjava.net/bily/comments/81471.html</wfw:comment><comments>http://www.blogjava.net/bily/articles/81471.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/bily/comments/commentRss/81471.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/bily/services/trackbacks/81471.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一、 选择题 下列各题 A ）、 B ）、 C ）、 D ）四个选项中，只有一个选项是正确的，请将正确选项的标记写在题干后的括号内。 1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 下列语句序列执行后， k 的值是 ( &nbsp;) 。 int m=3, n=6, k=0;while( (m++) &lt; ( -- n) ) ++k...&nbsp;&nbsp;<a href='http://www.blogjava.net/bily/articles/81471.html'>阅读全文</a><img src ="http://www.blogjava.net/bily/aggbug/81471.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/bily/" target="_blank">礼必风</a> 2006-11-16 11:10 <a href="http://www.blogjava.net/bily/articles/81471.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>