Win a copy of Rust Web Development this week in the Other Languages forum!

Gary Peck

Greenhorn
+ Follow
since Jun 03, 2003
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 Gary Peck

Well...first let me say that I am NOT a programming guru and when I see some of the people on here that passed with a 100%....that is NOT me!! I am a former PE teacher and have been programming for about 5 years professionally.
One thing of a surprise for me was the number of questions related to threading. I was told to expect maybe 3 at the most...the first 15 questions on my exam were related to threading.
18 years ago
After a LONG time of studying I am happy to say I passed the programmer exam (1.4) last Friday!
Thanks for all of the help!!!
18 years ago
Thank you for speaking my PE language!
However...you've gone and confused me again!! haha
You said:

So now if you see the hex value 0xff then you know that the binary representation is 11111111 or 255 (15 * 16 + 15 or 16^2 - 1).


but isn't 11111111 actually a negative number because of the 1 in the most significant position?
18 years ago
Does the 0xffffffff represent just a huge number that must be converted to binary before the shift?
So...each digit can be 0-9 a-f so that each shift of a digit changes the number by the power of 16?
It just seems so difficult to try and figure out what the number in hex converts to in binary to do the shift.
Am I totally making this harder than it has to be?
18 years ago
Could someone explain (in P.E. major language ) why the answer is f? I included the explanation, but it doesn't really make a lot of sense!

What is the result of attempting to compile and run the program?
a. Prints: ffffffff,ffffffff,ffffffff
b. Prints: ffffffff,ffffffff,7fffffff
c. Prints: ffffffff,7fffffff,ffffffff
d. Prints: ffffffff,7ffffffe,7ffffffe
e. Prints: fffffffe,ffffffff,ffffffff
f. Prints: fffffffe,ffffffff,7fffffff
g. Prints: fffffffe,7fffffff,ffffffff
h. Prints: fffffffe,7fffffff,7fffffff
i. Run-time error
j. Compile-time error
k. None of the above

If the left-hand operand of a shift operator, <<, >> and >>>, is of type int, then the shift distance is always within the range of 0 to 31, inclusive; and is specified by the least significant 5 bits of the right hand operand. Similarly, if the left-hand operand of a shift operator is of type long, then the shift distance is always within the range of 0 to 63, inclusive; and is specified by the least significant 6 bits of the right hand operand. The left shift operator, <<, shifts each bit of the left operand to the left a distance specified by the shift distance. A number of bits that is equal to the shift distance are shifted out of the left-most bit position and are lost. A number of bits that is equal to the shift distance are shifted in at the right. The signed right shift operator, >>, shifts each bit of the left operand to the right a distance specified by the shift distance. A number of bits that is equal to the shift distance are shifted out of the right-most bit position and are lost. A number of bits that is equal to the shift distance are shifted in at the left. The value of each bit that is shifted in at the left is equal to the value of the sign bit. The signed right shift operator maintains the sign of the left operand. The unsigned right shift operator, >>>, is similar to the signed right shift operator except for the fact that each bit shifted in at the left is zero.

18 years ago
Ken...why then would the -0.00 be -0.00? Why doesn't it come back as 0.00 as well?
A question i remember from the test had a line:
Daemon Thread(true)...or something like that...
how does this affect the thread code around it?
[ November 12, 2003: Message edited by: Gary Peck ]
I understand that for example a byte type contains 8 bits and can hold from -128 to 127. My question is this:
0111 1111 = 127
Why can't a byte store a 1 in the most significant spot(1111 1111)?
I think now that Im looking at it...that this would make it a negative number? What IS the value of 1111 1111?
18 years ago
I needed 31 and got 30 this morning....back to the ole drawing board!
I think it is simply used to give test-makers a better chance at failing people.
Ive heard that it is used in ticker screens where the bits shift with the screen??
That's about the only real life situation I have ever heard...and...I ain't takin THAT job!!
18 years ago
Sorry.... b1 is the following:
Byte b1 = new Byte("127")
18 years ago

PRINTS: False....this makes sense...two different objects

PRINTS: True ... makes sense because since there was no 'new' keyword the java pool uses the one already created

The question is: Why does this print False?
[ November 05, 2003: Message edited by: Gary Peck ]
18 years ago
I have a technical interview for a java position and was wondering if there is a section on javaranch that deals with these possible questions? I have heard from colleagues that have interviewed already that it was extremely difficult. If not on javaranch...does anybody know of a good site for examples. I have checked the web and found a few helpful sites but nothing that great.
Thanks
[ June 07, 2003: Message edited by: Gary Peck ]
18 years ago
Thanks Avi...that clears it up. If I understand correctly, when the code v=vh occurs, the v that is now referencing the vh object, is actually just the method parameter variable switching from the original v object and now referencing the vh object. The confusing part that is now clear is that the actual method variable in amethod() is still pointing to the original v object...thus the value of 20 rather than 10.
Thanks again!
18 years ago
Please look at the code below.
The final print out when run is:
10,0
20
This is confusing to me becasue it seems to me that when v=vh occurs, the object v should be changed, yet for some reason the final print of v.i is 20 and not 10.
Can someone explain?

public class ObParm {
public static void main(String[] args) {
ObParm o = new ObParm();
o.amethod();
}

public void amethod(){
int i = 99;
ValHold v = new ValHold();
v.i = 30;
another(v,i);
System.out.println(v.i);
}

public void another(ValHold v, int i){
i=0;
v.i=20;
ValHold vh = new ValHold();
v=vh;
System.out.println(v.i+" " + i);
}
}
18 years ago