Judy YU

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

Recent posts by Judy YU

I created a GUI applet using Java Swing and using the MotifLookAndFeel. The applet looks great on Solaris 8 platform,
but the size of TextArea changes on Windows which ruins the look of the GUI.
Can anyone give a clue about what might cause the problem?
Judy
22 years ago
I am a Sun certified Java 2 Programmer and am looking for an IT job in Atlanta, GA. You can check my resume at http://userwww.service.emory.edu/~yzhou01.
Judy
23 years ago
The great book I mentioned is Khalid A. Mughal 's "A programmer's guide to Java certification: A comprehensive primer", ISBN 0-201-59614-8. I bought it from booksamillion.com at the price about $32.
Judy
23 years ago
I passed SCJP2 with 94% today. It's not as great as what other people get (like 98%, 100%), but I am satisfied. I missed 3 out of 59, and I don't know which one I actually missed. The test is really straitforward, but the trip/traps used in mock exam are also in real test. I used RHE first, and then KR book for study, RHE sends me to cloud ( I was really confused by what they talked about in the book), but KR book brings me to ground. KR book is really a good one, very detailed and have a lot of test examples and review questions. I recommend it to everyone who don't know Java deeply.
Doing mock exam really helps to improve your scores. Sometimes, you know the concept, but you don't know the trick and you miss it. Mock exam will make you being moew careful. This is a good mock exam site created by maha: http:www.javaranch.com/maha.
Joining javaranch discussion group also helps a lot, seeing so many people passing SCJP2 every day encouraged me tremendously.
Thanks javaranch and all the people who helped me.
Judy
23 years ago
My question is as title.
And also wants to clarify several terminologies:
class fields only mean static variables, fields include static and non-static variables, instance members include instance variables and instance methods. Correct me if I am wrong.
Thanks.
Judy
The following code printed out "nullnull" instead of throwing NullpointerException at run time. Why?
public class AStringQuestion
{
static String s1;
static String s2;
public static void main(String args[])
{
s2 = s1+s2; // I would assume the exception will be thrown here.
System.out.println(s2);
}
}
Thanks.
Judy
In JQPlus standard test4, it is said that static methods are not inherited. Is that true? I understand that private methods are not inherited because it isn't directly accessible in subclass although it exists in subclass. But we can directly invoke statc methods of the supercalss in subclass, how can one say it is not inherited?
Confused.
Judy
Thanks for all your kind reply.
So now I see that the static method sleep() of Thread won't relinquish the lock of the object if it happened to be called inside synchronized method. And sleep() is definitely different from wait() since the latter must be called inside synchronized block.
But nobody answered my other question: what happened if interrupt() is called on this thread? I assume the thread will immediately relinquish the lock it holds if this method is called inside a synchronized block. But if the thread is interrupted while it is still in waiting state, the InterruptedException won't be thrown until the thread re-obtain the lock, and entering running state at the mercy of Thread scheduler. Right?
Question about another static method of Thread, yield(): java API says: Causes the currently executing thread object to temporarily pause and allow other threads to excute. So what kinds of threads will get the chance to excute? Those threads who have higher or equal priority as the current Thread? It is said that the when a Thread gets to run is platform-dependent because some platforms may use priority-preemptive mechanism,i.e, threads of lower thread never get chance to run before all other threads with higher priority die, and some platform have time-slice mechanism, in this case lower priority and higher priority thread alternatively get chance to run. Therefore, does this mean on different platform, yield() will enable different thread to execute, including threads whose priority is lower than current ones?
Judy
As far as I know, Thread releases the lock it holds when it enters wait state. How about when sleep(), or interrupt() method is invoked on the Thread object? Will the thread release the lock immediately?
In the deprecated suspend() method, the thread may keep the lock which may result in deadblock when the thread is suspended by other threads.
Thanks.
Judy
I compared this expression with "null" and ""(empty String", both resulted in false. So what will it return? Since the returned substring should include char at index 2, and exclude char at index 2 (according to the definition of this method), nothing should be returned. The code compile and run cleanly.
Judy
As the title, when we instantiate an object of a class by calling its construtor, eventually, it will ends calling its superclass constructor before initialize its own instance members and executing its own construtor body. The question is in the superclass, will the same thing happen? Will the superclass call its own superclass constructor before initializing the instance members and executing the construtor body of its own class? And will this go all the way up until the constructor of the Object class is called, and then start fall down?
Thanks.
Judy
I purchased the test and I think it's really good. It helps to clear 3 wrong concepts so far:
1. IN KR book, it is said that inner class(except static inner class ) cannot have static members. JQPlus points out that such class can have static members as well, as long as these members are defined as static final constants.
2. In KR book, annonymous class in static context is implicitly static, JQPlus and JLS both point out that annonymous class is never static.
I just have another question, can annonymous class in static context refers to both static and non-static members in enclosing class?
3. A wrong concept that I had for a long time: instance initializer can only access instance members. Actually, both static and instance initializer can access static and non-static members as long as there is no forward reference.
JQPlus has other good parts, such as detailed explaination. It's good.
Judy
Thanks for your kind reply.
As for question 2: in KR book , page 29, Khalid Mughal provides a chart which separated integer type from character type, although integral type includes both char and integer type. Did Mughal write it wrong? I am really confused.
Judy
I definitely think a boolean value takes a bytes. I confirmed it with following code:
import java.io.*;
public class TestIPApp {
public static void main(String args[]) throws IOException {
RandomAccessFile file = new RandomAccessFile("test3.txt", "rw");
System.out.println(file.getFilePointer() ); //0
file.writeBoolean(true);
System.out.println(file.getFilePointer() ); //1
System.out.println(file.length() );//1
file.writeInt(123456);
System.out.println(file.getFilePointer() );//5
System.out.println(file.length() );//5
file.writeInt(7890);
System.out.println(file.getFilePointer() );//9
System.out.println(file.length() );//9
file.writeLong(1000000);
System.out.println(file.getFilePointer() );
System.out.println(file.length() );
file.writeInt(777);
file.writeFloat(.0001f);
file.seek(5);
System.out.println(file.readInt());//7890
file.close();
}
}
I think the key is how we understand seek(int offset) method. seek(5) actually the next written/read byte is at position 6, like in array, index 5, because the first byte is at position 0.
Judy
As I understand, if class A extends class B, we can say that class A is a B, and if in the definition of class A, there is object C (such as Interface , class objects) as class or instance member, we can say A has C. Then, how about class A implements interface E, do we say A is a E? I saw in some mock exam, it is declared as A is-like-a E, but it is not an official term in Java. Can anyone help?
Question 2: is the declaration " all integer types are signed numbers " true or false? As I know, it is true because all integer types(short, byte, int, long) are signed numbers. If "integral type" is used here instead of "integer type", then it will be wrong since integral type includes char as well. Agree?