+ Follow
since Sep 20, 2000
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hans

FilterInputStream can not use FileInputStream object as argument.
FileInputStream fs=new FileInputStream("test.java");
FilterInputStream fi=new FilterStreamInputStream(fs);//compile is not ok
But I can code following :
DataInputStream di=new DataInputStream(fs);//compile is ok
Why? I get confusion.
I think FileInputStream is a subclass of InputStream.It sould be used in FilterInputStream constructor.Why compiler complain?
Who know reason,please explain.
Thank you.
1)A copy of the original event is passed into a listener method. true/false.
2)an object obj1 can access an object obj2 that is eligible for garbage
collection, then obj1 is also eligible for garbage collection.
Object ob1=new Object();
Object ob2=new Object();
Whether ob2 can be gc?
3)Given a TextArea using a proportional pitch font and constructed like this:
TextField t = new TextArea("12345", 5, 5);

Which statement is true?
A. The displayed width shows exactly five characters on each line unless
otherwise constrained.
B. The displayed height is five lines unless otherwise constrained.
C. The maximum number of characters in a line will be five.
D. The user will be able to edit the character string.
E. The displayed string can use multiple fonts.
Answer is B,D.I code prog.I find only D is ok.Because TextArea t's width and
height can be changed when you edit text in t.If I am wrong.Please correct.
Thank you.
I design an exception MyException is abstract subclass of Exception.
|_MyException(abstract class)
|_MyException1(not abstract class)

If I code a method Do().I think I can not throw MyException As
Do() throws MyException{}
If Do throw MyException1.I know I can delclare as
Do() throws MyException1{}
Whether I can declare as
Do() throws MyException{}.?Why?
Thank you.
1)Choose the correct statement about gridbag layout:
A. The weightx & weighty should have values between 0.0 & 1.0
B. If you specify the fill field is BOTH, there is no meaning to set anchor field
C. If you specify anchor field there is no meaning to set fill field is BOTH
Answer is A,B,C.I try it and find no one correct.Am I right?
2)What is the method used to schedule a thread for execution?
Answer is public void run(){}.I think is start();
3)Choose the correct one about thread:
A. The threads from one class ends at the same time.
B. when JVM exists the main method, it will stop only after all the
threads are stopped.
C. if there are multiple threads, reading or writing of data of class
is inconsitent.
D. programmer has to write a special program for garbagecollection in
multiple threads.
Answer is B,C.I think only C is correct.
4)Which statements are true about listeners?
A. The return value from a listener is of boolean type.
B. Most components allow multiple listeners to be added.
C. A copy of the original event is passed into a listener
D. If multiple listeners are added to a single component,
they all must all be friends to each other.
E. If the multiple listeners are added to a single component,
the order [in which listeners are called is guaranteed].
Answer is B,C.I see other answer only B is correct.Whether C is answer?
5)What might cause the current thread to stop executing?
A. An InterruptedException is thrown
B. The thread executes a sleep() call
C. The thread constructs a new Thread
D. A thread of higher priority becomes ready (runnable)
E. The thread executes a read() call on an InputStream
Answer is A,B,D,E.I think is only B,D.
6)Which statement is true about an inner class?
A. It must be anonymous
B. It can not implement an interface
C. It is only accessible in the enclosing class
D. It can only be instantiated in the enclosing class
E. It can access any final variables in any enclosing scope.
Answer is E.I think No one is correct.
7)Consider the following code:
1. public void method(String s){
2. String a,b;
3. a = new String("Hello");
4. b = new String("Goodbye");
5. System.out.println(a + b);
6. a = null;
7. a = b;
8. System.out.println(a + b);
9. }
where is it possible that the garbage collector will run the first time?
A. Just before line 5
B. Just before line 6
C. Just before line 7
D. Just before line 8
E. Never in this method
Answer is C.I see other answer is B.I don't know which is correct.
Which of the following statements are true about setLayout() method
in java.awt.ScrollPane
1.Does nothing.
2.Throws UnsupportedMethodException when called.
3.It is not overriden in java.awt.ScrollPane.
4.Sets the layout to the specified Layout Manager.
Answer is 1.Why?
I think 4.
2.)What means is demon threads ?I read book JAVA 2 EXAM CARM
does not include the concept.Whether I need to know it,if
I want pass EXAM?
1)Anonymous Inner can implement an interface, extend a nonstatic class(but not at same time).True or false?Why?How to complete?
final int i=2;
byte b=i;
the compile is ok.Why do not need explicit cast?
Thank you!

class Super
{ int index = 5;
public void printVal()
{ System.out.println( "Super" );
class Sub extends Super
{ int index = 2;
public void printVal()
{ System.out.println( "Sub" );
public class Runner
{ public static void main( String argv[] )
{ Super sup = new Sub();
System.out.print( sup.index + "," );
The result is (5,Sub).Why is not (2,Sub)?Who know reason.
Thank you.
The finally statment execution finish .The rest of the method countinue to run.(True or False)?
class ValHold{
public int i = 10;
public class ObParm{
public static void main(String argv[]){
ObParm o = new ObParm();
public void amethod(){
int i = 99;
ValHold v = new ValHold();
}//End of amethod
public int another(ValHold v, int i){
v.i = 20;
ValHold vh = new ValHold();
v = vh;
System.out.println(v.i+ ","+i);
}//End of another
I run the program and get result (10,20),Why don't get result(10,10).I think v=vh has sent vh object's fields to v object.why when print vh.i ,it dose not print v object's i.Who know reason.
Thank you.
Interface don't use new method
example: Runnable r=new Runnable();It;s wrong I know reason.
But following question.
interface IFace{}
class CFace implements IFace{}
class Base{}
public class ObRef extends Base{
public static void main(String argv[]){
ObRef ob = new ObRef();
Base b = new Base();
Object o1 = new Object();
IFace o2 = new CFace();//Why it can use new method
Answer is 1,2,4.
Why 1 is correct.I compile the program.The answer is right.But I don't know reason.Who know ?
Thank you help.
byte b=0;
Compile will get 1 error.The reason I know.
But byte b=0;
can not make error.why ?I don't know.Who can give me an answer.
Thank you.
a char can get value from'\u0000' to '\uFFFF',but char a='\u000A' get 1 error when compiled.Why?
Que3.)I get confuse on String immutable.Where can I get good information about the String immutable?How use String functions?

The Component class implements the MenuContainer interface,why Frame class continue to implement the MenuContainer interface.I think Frame extneds from Component class,it automatically have the property of MenuContainer.So the other subclasses of Compoent can add Menu in their container.True of False.Why?
Thank you.