Pam Doucette

Greenhorn
+ Follow
since Mar 13, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Pam Doucette

I want to use PL/SQL functions to add business logic / modifications to a set of results. Rather than return just one value from an Oracle function, can I use Oracle collections and objects to return a set of results back to Java?
I'm using Oracle 8i - and I've been fishing around at lots of documentation - but haven't found any magic answers yet.
Would appreciate any advice....
Is there a way to do this using Oracle collections and Oracle objects?
23 years ago
Percy - hang in there. I had troubles passing this exam, too. One thing that helped make the difference for me was the Java Exam Cram by Bill Brogden. I didn't think the Roberts book was enough. The Brogden book gave additional notes on subtle, yet key points that helped make the difference between pass and failure. Marcus' exams were awesome, too.
I also didn't have alot of IT experience, and Java is my first "heavyweight" language. This makes it harder to learn - but the success is so sweet when you get there! And, the more you learn, the easier it gets to learn because you have the foundation behind you.
Good luck. I'll look forward to seeing your "I PASSED" message next time around!
23 years ago
I have 2 small children and a full-time job, so no way could I study 4 hours a day like some people have done.
Thanks to Java Ranch and Marcus Green's mocks, I passed with a healthy 83% - and I'm taking the summer off!
23 years ago
Struggling with Threads and synchronization, and came up with this code that helps me to understand it a little better. Thought I'd share it with you.
This shows the impact of having synchronized and unsynchronized methods updating the same variables of an object. It shows how the unsynchronized method does not acknowledge / respect the lock. Run and see...
class ObjTest
{
static int number = 0;

public static synchronized void incNumber(Holt h)
{
System.out.println(h.getName() + " in synch method. number = " + number);
try{
Thread.sleep(2000);
}
catch(InterruptedException e)
{}

number += 1;
System.out.println(h.getName() + " finish synch method. number = " + number);
}
public static void incNumber1(Holt h)
{
System.out.println(h.getName() + " in plain method. number = " + number);
number += 1;
System.out.println(h.getName() + " finish plain method. number = " + number);
}
}
public class Holt extends Thread{
private static ObjTest ot = new ObjTest();
public static void main(String argv[])
{
Holt h = new Holt();
h.go();
}
Holt(){}
public void go()
{
Holt first = new Holt();
first.start();
Holt second = new Holt();
second.start();
}
public void run()
{
for(int i = 0; i<5; i++)
{
ot.incNumber(this);
ot.incNumber1(this);
}
}
}
When an object is locked as part of synchronized(obj), this this lock the entire object, or does it only lock access to it's synchronized methods and synchronized blocks?
I believe that if you create a 6X6 container with a GridLayout you create 36 equally sized cells. If you you only add 5 buttons, the buttons will occupy the first 5 cells in the first row, left to right. The rest of the container will be white space.
If you add more buttons than cells available, the GridLayout will add a column and re-draw the grid to accommodate the changed positioning of the components.
I think that's right - let me know if it isn't.
I still don't understand why a) wouldn't be included as a legal method. The Sub class is the public class - so shouldn't it be the one that is the same as the file name and contain the main method? The main method declaration looks right to me, too.
Thanks for your excellent suggestions. Wish me luck separating my spaghetti!
23 years ago
I've run into a couple of instances when I've updated some java class files that will impact the jsps. However, the jsps themselves didn't need to be changed - and consequently were not re-compiled to show the impact of the other classes.
Is there a way to force a set of jsps to recompile besides deleting the class versions?
23 years ago
Is there a good debugger or editor for jsps? It gets awfully tricky trying to sort out the java, HTML and javascript to correct errors.
On the same line, are there best practice guidelines for integrating these technologies cleanly so the jsp doesn't end up looking like spaghetti?
23 years ago
Huge help. Thanks to all. I've played around with the code, too. Nothing beats first hand experience!
I'm still having trouble with threads. What happens if a subclass of Thread overrides the start() method?
Can anyone point me to any good on-line material on Threads so I can finally GET this!?
Thanks.
There is a good explanation of bit shift operators on Marcus Green's site at http://www.jchq.net/tutorial/BitShift.htm
When I was trying to figure this out, I always set things up for myself as follows:
Bits are set up on base 2.
32>>1(answer is 16)
keep in mind that the 32 will be promoted to an int before evaluating the expression - I'm only putting in enough bits to show where the 32 is coming from:
32 16 8 4 2 1
------------------------
32 in in bits: 1 0 0 0 0 0
right shift 1: 0 1 0 0 0 0 = 16
2<<32(answer is 2)<br /> 2 will be promoted to an int before evaluating the expression. Marcus has the accurate explanation about how shifting uses the modulo operator - but I just think of it as "wrapping around." Left shifting by 32 inserts 32 0s to the right of it - for a total of 64 bits. However, an int can only hold 32 bits, so it will take the most significant 32 bits - which is exactly the bit pattern you started with.<br /> -32>>>1(answer is 16)
Actually - when I run this I get a super long positive number. Negatives are represented differently than positives. When you do an unsigned right shift by one - it inserts a 0 in the beginning of the number, changing it to a positive number. Because it used to be a negative (with alot of ones because of the way negatives are stored in bits), the number becomes huge. Marcus has a detailed explanation for this.
Hope this helps.
I'm no expert, but this is what I think is going on.
call to new Processor() goes to instantiate a Processor object.
This object instantiation implicitly calls the superclass constructor.
The superclass constructor calls this.MethodA - but the object you are trying to instantiate is the Processor - so it calls the Processor's MethodA - before the Processor object has actually been constructed and instance variables have been assigned.
I added some comments to the code to demonstrate - but I could be wrong. Anyone have a better explanation?
class Process {
byte b=127;
Process() {
System.out.println("Process constructor initialized");
System.out.println("Value of b it " + b);
this.methodA();
System.out.println("Process constructor finished");

}
void methodA() {
System.out.println("Value of Super b is = " + b );
}
public static void main(String [] args) {
Processor p = new Processor();
}
}
class Processor extends Process {
byte b=126;
Processor() {
System.out.println("Processor constructor initialized");

System.out.println("Value of b = " + b);
System.out.println("Processor constructor finished");

}
void methodA() {
System.out.println("Value of Sub b = " + b);
}
}
Output is:
Process constructor initialized
Value of b is 127
Value of sub b = 0
Process constructor finished
Processor constructor initialized
Value of b = 126
Processor constructor finished
Interesting...
You can assign the value at the time you declare it (int i = 0) to avoid a compile error.
Alternatively, you can assign the value in the constructor, or within a method.
Thanks for bringing this up. I'd run into the same problem....