Kathy Cai

Greenhorn
+ Follow
since Jan 13, 2004
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 Kathy Cai

I passed SCJP 1.4 with score of 86. My success is attributed to 1) Sierra&Bates book and 2) the Javaranch and its members. I am very happy. However, on the other hand I am concerned about how much value the SCJP cert. really has.
Although getting a score of above 90 or even 80 is not easy, I think the passing score of 52 (i.e., 31 of 61 questions answered correctly) is set a little bit too low. It really does not need a lot of effort to just answer 30+ questions correctly. I�d like to know how many people in percentage actually failed in their first try in this test.
20 years ago
Corey,
Thanks. I will start to use CODE" tags.
Thank you for answering my question. But this time I did not get the point well. It seems instanceof has very limited usage. Say, if the RHS of istanceof is class Animal, I can not put an arbitrary object on its LHS. For example, I can not put �t� an object of String type there. since (t instanceof Animal) is not allowed. This means when I write the code I have to know the object to be tested must be from either the Animal class or its superclass / subclass.
I guess I do not exactly know the intention of instanceof.
Kathy
The following code is from Sierra&Bates book. It would not compile. The error message says �inconvertible types.� I donot know why one can not check whether t is an object of type String. Sorry I do not understand such fundamental stuff.

Edited by Corey McGlone: Added CODE tags
[ February 25, 2004: Message edited by: Corey McGlone ]
I ran the attached code and got the result:
22 7
How to explain this line:
{k=7; }
If I remove the curly brackets, it will fail to compile it. Why?
Thanks.
---
public class junk {
int i = 22;
int k;
void go() {
System.out.println(i + " " + k);
}
{k=7; }
public static void main(String [] args) {
junk j = new junk();
j.go();
}
}
Corey,
Thank you very much for spending time in writing such clear explanation. I really appreciate it. Now I have much better understanding of this topic.
Regarding using a third-party object as lock, this object must be referenced by the Thread objects (i.e., InSync objects in this example)via a member variable. Do you agree?
Kathy
Attached is the code for Exercise 9-2 in Sierra and Bates' book. I do not understand why we have to use "letter" in synchronized(letter). I do not know why "this" would not work in this example. Further, on page 523 of the book, they mentioned to use some third-party object as the lock. I am totally confused. Thank you for your help.
// Sierra book - Ex 9-2

Edited by Corey McGlone: Added CODE tags
[ February 24, 2004: Message edited by: Corey McGlone ]
In Mughal's mock exams, the following question is tough. I have no clue to answer it. Please tell me where I could find such information. Also, I am not sure if "yeild" is Mughal's typo or intention.
Which of the following method names are overloaded?
Select the three correct answers:
o The method name yeild in java.lang.Thread
o The method name sleep in java.lang.Thread
o The method name join in java.lang.Thread
o The method name wait in java.lang.Object
o The method name notify in java.lang.Object
Both show1 and show2 in Q2 class are overriding methods in the attached code. However if I run the code, I got the following results:
Show1 in Test class
Show2 in Q2 class
That is, show1 in Test class was not overridden. I don't know why modifier "static" caused this. I appreciate your explanation.
----
class Test {
static void show1() {
System.out.println("Show1 in Test class"); }
void show2() {
System.out.println("Show2 in Test class"); }
}
public class Q2 extends Test {
static void show1() {
System.out.println("Show1 in Q2 class"); }
void show2() {
System.out.println("Show2 in Q2 class"); }
public static void main(String[] args) {

Test t = new Q2();
t.show1();
t.show2();
}
}
I was wondering if one would get a partial score for a question if one selected some but not all the correct answers. For example, the correct answers to a question were A, B and C, but one selected A, B and D. Would he/she get a partial score for this question? Thanks.
Thanks. The question and answer were from Sun's Learning CD-ROM JAVA Programming Language.
I agree your comments. However, this means the original answer is not correct. Please note that there is "NOT" in the question. If choice "C" is not correct, which choice is correct?
---
Which statement about Threads is NOT true?
A. Threads allow you to perform more than one task in your program at a time
B. The three elements of a thread are the CPU, the code, and the data
C. There are two ways to create a thread: extend the Thread class or implement the Runnable interface
D. Threads are faster to load, more scalable, and easier to manage than processes
---
The correct choice is C. But I do not get it. Can anyone explain? Thank you.