Lori Battey

Ranch Hand
+ Follow
since May 17, 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 Lori Battey

If you have different projects going on, use a colored marker and mark the top of the cards - you can do the whole package of cards when you first open them up. This way you can "color code" your projects and they won't get confused!
I haven't tried to access that page in a few weeks but it was gone last time I looked as well. My thoughts were that maybe they were updating them...

Lori Battey
Funny! I answered this same question on another board earlier with pretty detailed explanation. I'll cut and paste it here and maybe it will help some!
Java always passes by value. The difference between Object values and primitive values is that the "value" in an Object is it's memory location.

When a and b values are passed to the method, there are 2 Object "handles" pointing to each memory location.

a.append("more") appends the String "more" to the memory location referenced by a in the local method (which is the same as a in the main method).

b = a makes the second "handle" drop it's reference to the original b StringBuffer and now it also points to the memory location held by a. Note that if you did a System.out.println(a, b) within the swap() method, you would get "A is one more" "B is one more".

When the method swap completes, and control passes back to the main method both of the second "handles" to the memory location die with the method (and are available for garbage collection because they are unreachable) and what prints is "A is one more" "B is two"

Lori Battey
Q1. What is the diffrent b/w Abstract class and Interface ?
**abstract classes are classes and can only be extended. Abstract classes can have non-abstract methods as well. Interfaces can only be implemented so they are more flexible in this regard, but the methods are implicitly abstract.

q2. Here is the figure of allowable primitive conversion.
byte-> short -> int-> long-> float-> double

My simple q. is ...the Size(bits) of long and float are the following then why float is higher than long in this casting highrarchy.What I am trying to say why we need casting to keep a float value in long ?
long 64 0L
float 32 0.0F
***The reason a float must be cast to a long even though they hold the same number of bits is because of the "precision" factor. You must specifically cast to state to the JVM that you as the programmer are aware of the potential loss of precision.
q3.We know about constructor,but what is the use of private constructor ? i.e. wht. is the concept of private constructor...explanation with example will be very helpful for me.
*** Obviously, a private constructor could only be called from the class it is in (a "this(arg1, arg2) type usage). Giving an off the cuff example might be a little more difficult...not coming up with anything....sorry!!
q4. (Ref. RHE, Page No: 240 )Six numeric classes provides methods to retrieve the wrapped value as a byte , a short....The retrival methods are:
According to RHE , the retrival method of int is given
" public int bytevalue() " shouldn't it be intvalue()
Is this wrong, or I am understading wrong. Pls..confirm this.
***I'm not sure what your book says here. I have both the first and second edition of RHE and my looks fine. Yours must be a misprint. An int uses intValue().

***Good questions, all!
Hi Preeti! Good to see you over here too!
The RHE book (2nd edition) covers what you should know. It's a fairly long chapter but AWT is a fairly diverse subject and you really never know what will be asked. You should know at least how the layout managers will react in different situations, know your listener, event and adapter classes.

Good luck!

23 years ago
Something new for me too!! Thanks!
23 years ago
I put this together to help some others...I could use some input on shifting of negative numbers but the remainder should be useful! I have it in a Word 97 document and am not sure how the formating will show up as I am copying/pasting it in here. If anyone would like the word document emailed, leave me you email address and I'll forward it.
Numeric Conversions and Bit Shifting

To convert a decimal number into binary, octal or hexadecimal, you need to understand �powers� of each base system and be able to figure the positional value representation. If I would have to convert from octal to binary, or hexadecimal to binary, I would convert the original value to decimal and then convert to the second base system. There may be an easier way but this works for me!
Also, if you need to shift a negative number, get the positive value in binary and then reverse the bits. Do your shifting, and then reverse your bits again to find the value of the shifted number. Remember that your number could be positive or negative based on the type of shift you do � get the value first, then make the sign appropriate for the shift.

Binary positional valuesBASE 2 (x2 or to the power of 2)

binary #10110011
positional value128032160021
total decimal value179

When doing bit shifting, the left operand is assumed to be an int (32 bits) unless it is specifically stated to be a long (64 bits). The shift will be performed upon the left operand value the number of times stated by the right hand operand. Something to remember is that shifting is only able to be performed by the number of bits available � 32 or 64. If you are given a shift larger than the bit value of the left operand you need to modulo by the bits available. In our instance above 179 (int) >> 45 is actually 179 >> 13 (45 % 32).
The effect of >> is dividing by 2 for every shift (remainders are truncated, not rounded) with the filled in bits being zeros for positive numbers and ones for negative numbers. Using the example above, 179 >>> 2 is the same as ((179 / 2 = 89) / 2 = 44). See the example below.

binary # right shifted 2101100
positional value3208400
total decimal value44
The effect of >>> is the same except the filled in bits are always 0, automatically making negative numbers positive.
The effect of << is multiplying by 2 for every shift. The filled in bits are always 0. Depending on the size of the shift, a positive number could be negative and a negative number could be positive.
Octal positional valuesBASE 8 (x8 or to the power of 8)

Octal # starts with 017426
positional value40963584256166
total decimal value7958

Hexidecimal positional valuesBASE 16 (x16 or to the power of 16)
0 to 9 then A to F
Hex # starts with 0x196AEB=11
positional value6553636864153616014C=12
total decimal value104110
Hopefully this helps!
23 years ago
Great information! Thanks!!
This brings up another question though...should you set rowWeights and columnWeights for each row and column? I know when you set them using weightx and weighty you are specifying which row/column should be the "stretchy" one (I guess you can specify how much "stretchiness" as well). When using rowWeights and columnWeights do you have these same options of setting how much "weight" each row/column has?
Sorry to ask so many questions but I'm brand new to gridBagLayout. Got the other ones down!
Thanks for everyones help! I love JavaRanch!!
23 years ago
Never mind...I now see that you changed the wording to the question...
My bad!!
23 years ago
You "corrected" a question that had the correct answer to begin with...it should be changed back to "d) none of the above".
The only way these two strings could have returned "true" is if an answer of
had been provided and this isn't one of the options so d) is the only possible answer.
23 years ago
an updated link to the updated question... :-)
23 years ago
According to all I've seen, A) is incorrect. When you initialize an array with the keyword "new" you must either state the size or input the data so the space can be allocated on the heap. At declaration time you don't need the size but when instantiating, you do...
23 years ago
What mock is this from?? Looks like one I'd like to take!!
23 years ago
I was trying not to use weightx and weighty per RHE Complete Java Certification (latest edition) on pages 318 and 319. It suggests that rowWeights and columnWeights is a simplified way. I am just not able to find any code examples showing this "simplified" way!
23 years ago
Problem I see is that the array doesn't know it's size...