Kathy Hodgson

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

Recent posts by Kathy Hodgson

Thank you both; I'll try to find more out about these positions. I know the Servlet/JSP part (also JDBC) but am just in the process of getting into EJB with Ed Roman's book and possibly the new certification ( I'm aware of the endless debate about whether it helps you get a job, but I really found the SCJP useful in solidifying my knowledge and in saving time looking things up when I'm programming.)
Kathy
21 years ago
Does anyone know, when J2EE is mentioned as a prerequisite skill for a position, which among the J2EE technologies are likely to be critical?
Kathy
21 years ago
On different practice tests, I had been seeing answers on using boolean assignments in conditional statements which seemed inconsistent to me, so I tried the following:
public class testIt{

public static void main(String[] args){

boolean b = true;
if (b = false)
{ System.out.println("b is false");}
else
{System.out.println("b is true");}
System.out.println("after conditional, b is " + b);
boolean c = false;
if (c = true)
{System.out.println("c is true");}
else
{System.out.println("c is false");}
System.out.println("after conditional, c is " + c);

}
}
My results were:
b is true
after conditional, b is false
c is true
after conditional, c is true
How can this be? The assignment of the true to c, which was previously false, seems to have changed it right away, so that it is reset in time to go into the true block. However, the assignment of the false to b, which was previously true, seems to be delayed somehow so that it goes into the wrong block and then resets when it's too late!
Thanks to all of you, I'm finally getting a handle on this. I'm going to go through some of Dan Chisolm's exams this afternoon. Marlene, I can't claim that I understand everything you are writing, but certainly enough to help me rework my mental images, which seem to be what was getting in the way here. Your comments also make me aware of how much more there is for me to learn, which I think is a good thing!
Kathy
Sorry, I still don't understand, because display() is inherited, and it is being called on s2. At compile time, Java knows that I want s2's display(), not s1's. So if I'm calling display from within the s2 class, and there is no object dot-operator prefix when the String s is passed to println from within s2's display, why doesn't the method assume that I want the String s of the class I'm calling the method of? I tried putting in a "this" before the s but got the same result - "S1." So the compiler thinks my instance will be an instance of S1 even though I have told it explicitly that my instance is an instance of S2.
The only way any of this makes sense to me is if the child class doesn't really have any method it inherits without overriding - in other words, it is not calling its own invisible copy of the display method (which is how I thought method inheritance worked) but is calling its parent's display method. If a child class inherits a method without changing it, doesn't it really have it at all?
Kathy
The code below is from one of Jamie Jaworski's practice test questions; I tried it and it does what he says it does but I don't understand why S1 prints for the String s instead of S2. The reference is to an instance of S2. S2 inherits display(), so why isn't that call printing S2's own String s instead of its parent's? I'd understand why if the instance was assigned to an S1 reference, but not as it stands, since I thought for a variable the reference type determined which you got. Could somebody please explain it?
Code:
public class Question{
String s = "Outer";
public static void main(String[] args){
S2 s2 = new S2();
s2.display();
}
}

class S1 {
String s = "S1";
void display() {
System.out.println(s);}
}
class S2 extends S1{
String s = "S2";
}
In one of the questions on the Jxam mock exam, this code was given:
String s = null;
if ((s!=null) && (s.length()>0)) ...
The answer said a null pointer exception would be thrown because the entire expression had to be evaluated. But I thought the whole point of the shortcut operator && was that if the first condition was false ( and here it is because s is null ), you never looked at the second part. Am I missing something here or is the answer which is given incorrect/
Kathy
Thanks, Tim. Although neither of those worked, you got me on the right track. I wasn't seeing any option you mentioned to enable or disable the 1.4 plugin so I thought maybe I didn't actually have a plugin. So I went to the beta version of the Roundup and downloaded the version 1.3.1_06 plugin. Now I saw an option similar to what you mentioned. I left it enabled and I now can do the roundup.
One more question for you or anybody - what about the option to enable/disable the JIT compiler for virtual machine which is just below the plugin option? Should that be on or off or doesn't it have anything to do with running Java? It sounded from your suggestions like Microsoft IE has a Java vm running as well as whatever I downloaded from Sun and I don't want to cause more conflicts that are going to interfere with any of the practice exams and applets I'm trying to go through now.
At any rate, it's good to see the cows again!
Kathy
Thanks, Jose, especially for the example of the argument-defined anonymous class, and Jim, for the explanation of the terminology differences. I think, after trying to compile some code, I finally understand the restrictions that apply to anonymous classes when they are within methods and when they aren't. I also appreciate the reassurance that the test is going to show something to ask about when, as here, the semantics seem a little puzzling.
Kathy
On one of the K&B MasterExam questions, a correct answer to a question was that "a method-local anonymous inner class cannot access non-final local variables."
From the K&B book, I thought method-local and anonymous inner classes were totally different; for instance, the method-local ones can be abstract (or final) and strictfp from what I've read on other practice exams but I don't think the anonymous ones can (except that I think final is understood). So is the idea that method-local rules about modifiers not apply to anonymous classes within methods but rules about what the anonymous classes can access do apply? In other words no getting at non-final locals; also no getting at outer class instance variables if the method the anonymous class is within is static? And where do argument-defined anonymous inner classes fit into all this? If they are defined in the argument passed to a method, does this make them method-local anonymous inner classes too?
Kathy
Thank you, Bert! I have contacted them, and they sent me an unreleased version that works fine. There is one problem that isn't causing me any difficulty but I thought you might want to know about before it is released to everyone: the letters referenced in the part that gives the correct answer on each open book test problem do not always match the letters in the question itself. The test marks you as correct or incorrect on the basis of the letter(s) you selected in the question itself, but if you look to see what you did wrong, the explanation may say "letter b is wrong because..." when that wrong choice was really letter a. Just makes me think a little harder... at any rate, I appreciate your response since I'm now able to use the test.
Kathy
I've installed Java 1.4.1_01 and gotten rid of my earlier versions and can no longer run the Rules Roundup - I can't see the cows! The introduction says to disable the option to use Java 2 v1.3.1_02 for applets since I've got a newer version installed but I don't know where to get to that option in XP. Does anyone else know?
Kathy
Rishi,
Just the opinion of another greenhorn, so hopefully somebody will chime in if this is wrong, but I think this is what's happening:
You can only get access to your class's instance variables once the superclass constructor runs. When you have the call to this in your constructor, the compiler can't insert its no-arg call to the superclass constructor, so your class's instance variables aren't available yet. Remember you can't have BOTH this and super calls in the same constructor. When you take the this call out, now the compiler can insert that super constructor call, and when it returns from that call, your program can get at its instance variables which are initialized to 0.
Kathy
Rishi,
Just the opinion of another greenhorn, so hopefully somebody will chime in if this is wrong, but I think this is what's happening:
You can only get access to your class's instance variables once the superclass constructor runs. When you have the call to this in your constructor, the compiler can't insert its no-arg call to the superclass constructor, so your class's instance variables aren't available yet. Remember you can't have BOTH this and super calls in the same constructor. When you take the this call out, now the compiler can insert that super constructor call, and when it returns from that call, your program can get at its instance variables which are initialized to 0.
Kathy