Greg Windwall

+ Follow
since Dec 12, 2002
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 Greg Windwall

I don't think that the removal of a.join() would help anything. You can't run a single instance of a thread multiple times, which is what is being done here with two a.start() lines. You get the same error with:
class A implements Runnable {
public void run() {
public static void main(String[] args) {
Thread t1 = new Thread(new A());
[ December 17, 2002: Message edited by: Greg Windwall ]
I have a few questions about yield():
Does calling Thread.yield() cause the current
running thread to give up it's lock, if it has
I know that calling Thread.yield() might not
cause another thread to run, but does the
yeilded have to at least "visit" the Ready
state? This is related to the lock question
The object created on line XXX is referenced by "c", and "c" is returned by the method. So although the reference variable "c" goes out of scope at the end of hte method, the actual Object has a reference in the calling method.
I should have prefaced this by stating I was interested in compile-time behavior. The line:
obja = (Object []) c2; // 2
doesn't issue a compiler error, but does give a runttime error.
I was playing around with casting and came up with the following code, I'd like to make sure I understand what is going on.
class A {
public static void main(String[]a) {
Object[] obja = null;
Cloneable c2 = new Cloneable() {};
obja = c2; // 1
obja = (Object []) c2; // 2
obja = (Object []) new Cloneable() {}; // 3
obja = (Object []) (Object) new Cloneable() {}; // 4
Compiler errors occur at lines 1 and 3. I understand why 1 causes a problem, but want to make sure I know what is going on at line 3. By using new Cloneable() {}, am I creating an anonymous inner class that implements Cloneable, and this fails because the only class that can be cast to an an array is Object? Which is why the double cast on 4 works. Is this correct?
And in case you're wondering, no - I don't usually double cast expressions, by studying for this exam takes you down some pretty weird paths ...
[ December 15, 2002: Message edited by: Greg Windwall ]
For the code:
public class TestQ24 {

public static final StringBuffer style =
new StringBuffer("original");
public static void main (String[] args){
TestQ24 tq = new TestQ24();
tq.modify( style );
System.out.println("Now " + style );
public void modify( StringBuffer sb ){
sb.append(" is modified" );
the selections below should have "Now ...":
a Compiler objects to modification of a static final variable
b Output of "original"
c Output of "original is modified"
d Output of "is modified"
For this question I got radio buttons, allowing
only one selection. I believe more than one
is correct.
public class SomeTest {
static int[] x ;
static int[] y = new int[20] ;
static String[] s1 ;
static String[] s2 = new String[20] ;
The following options make statements about the results of various operations executed before any change has affected these variables. Which of these statements is true?
a The logical test x == null will return true.
b The value retrieved by addressing y[ 0 ] is 0.
c Addressing the element s1[ 1 ] produces a null value.
d Addressing the element s2[ 1 ] produces an empty String.
For the following:
boolean hashFlag = (x.hashCode() == y.hashCode());
boolean equalsFlag = x.equals( y );
boolean eqFlag = ( x == y ) ;
I would think the statement:

"If equalsFlag is false, then eqFlag must be false"
should be true. If equalsFlag is false, then the contents of x and y must be different, or they are of different types. Either way, they can't occupy the same memory location.
The exam was helpful, it pointed out my weak spots. You have a passing grade of 61.5% - isn't the real exams passing grade lower, something like 51%?
[ December 15, 2002: Message edited by: Greg Windwall ]
[ December 15, 2002: Message edited by: Greg Windwall ]
[ December 15, 2002: Message edited by: Greg Windwall ]
What is the taxomony of "keywords" and "reserved words", i.e. are they both the same, or is
"goto" a reserved word but not a keyword,
and is "final" a keyword but not a reserved word?
And where does assert fit into this? Is it now
considered a keyword? Only if insertions are
Would InsufficientChocolateException be checked
or not!?!
I was running through Dan's Mock Exams, and am curious to know if memorization of all RuntimeExceptions is required for the (1.4) exam?
Thanks for having this valuable resource available to us, Dan!
Why does the LinkedList class explicitly implement the List interface? It should implicitly implement the interface through the AbstractList class, shouldn't it? Does the "implements List" just serve as a reminder?
[ December 12, 2002: Message edited by: Greg Windwall ]