Bob Sherry

Ranch Hand
+ Follow
since Jun 27, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bob Sherry

I am working on a program that is computational intensive and in certain cases, I am getting wrong results. I believe it is due to a floating point underflow. I can and should test for the division to be 0.0. I am not doing that.

It seems to me, that in the modern era, programmers want to use try and catch. In this case, I will use an if. It really does not matter.

Bob
1 week ago
Here is code that demostrates the issue:

1 week ago
With floating point, if you divide a very small number by a positive integer greater than 1 you might end up with 0.0. This is known as underflow. Is there a way to catch this exception in Java?

Thanks,
Bob

1 week ago
I would be skeptical of a company that wanted to see more than 50 lines of my code especially before the interview. If I was asked for sample code, I would just send them a 50 line example. They are not going to have the time to look at lot of my code.

Bob
1 year ago
Please consider the following code fragment:

It is based on an example from a book but I added the authorName as type JLabel. I want it to appear near the bottom of the window on the right side so I added the call to setBounds. However, it still appears on the left hand side of the window. I am using the default layout manager. What should I do so the label appears on the right side of the window near the bottom?

Thanks,
Bob
1 year ago
It is my belief that data in the class is best defined after the methods. My reasoning for that is that the user of the class does not care about the data. He just wants to call the methods of the class.
For exmaple, I would write

instead of:

Please comment.

Bob
1 year ago
You suggested this:

This does not seem safe to me because I think of this.coeff as a pointer and setting it to arguments that are on the stack will cause problems when the method returns. Are you sure it is safe?
Bob
1 year ago
I would expect the following code to compile:


However, it does not. The error message is: error: generic array creation
The problem is with the line that starts with: this.coeff =
Is there a problem creating generic arrays in Java?

Bob
1 year ago
If I write the following statement in Java:

can I count on the function call of f occurring before the function call in g? I am fairly sure that you cannot in most languages include C and C++.

Bob
1 year ago
This expression is complicated:

The trick is to put in parenthesis so it is clear which operators are done in what order. Now we have the expression:

The term x + 3 evaluates to 7 and y ++ + x * y evaluates to 14. We then compute 7 & 14 and come up with 6.

Does that make sense?

Bob
1 year ago
I have defined a class called ElectricalPart. I have also defined the following variable:

I would like to write something like a pair of for loops to process each member of the map. Would doing it with one for loop be better. How would I do that?

Bob
1 year ago
Please consider the following Java fragment where there are two classes defined: Tire and Radial. The class Radial has Tire has its super class. That is, Radial extends Tire.

The call to add generates the following compiler error:
   error: no suitable method found for add(Radial)
   parts2.add( t1 );
Since t1 is of type Radial, it is of type Tire therefore I expected it to work. I tired putting in a cast of t1 but that did not work either.

Bob
1 year ago
I just passed Sun's programmer exam and I am thinking about taking the Developer´┐Żs exam. However, I am concerned that the project is a lot of work. How long does it typical take to complete the project?

Thanks
Bob
I just passed the SCJP 5.0 exam with a 69. I found the exam to be very tiring. I believe the key to passing this exam is to know the standard classes very well. I am not convinced that this exam is a good measure of somebody's ability to program in Java.

Bob
10 years ago
Please consider the following Java program from the John Meyer's
SCJP 5 Mock Exam simulator:

class test {
public static void main(String[] args) {
test inst_test = new test();
int i1 = 2000;
int i2 = 2000;
int i3 = 2;
int i4 = 2;
Integer Ithree = new Integer(2); // 1
Integer Ifour = new Integer(2); // 2
System.out.println( Ithree == Ifour );
inst_test.method( i3 , i4 );
inst_test.method( i1 , i2 );
}
public void method( Integer i , Integer eye ) {
System.out.println(i == eye );
}
}

It seems to me that the correct output should be: false false false
because we are comparing address of unique items. However, the correct
output is: false true false.

I am hoping that somebody can explain to me why.

Bob