Katrin Lüthi

Greenhorn
+ Follow
since Aug 22, 2008
Merit badge: grant badges
For More
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 Katrin Lüthi

Thanks... The problem was (from Self Test Chapter 1, Question 6 in K&B



does not compile if the method is like:



What is the matter?
Actually, you can also (additionally to what is stated as correct answer) put in a call to "this();" as first line in the constructor public AgedP(int x).
All the components (this, (, ), are present for choosing and the space is provided, too.

It is not necessary, but doesn't do any harm and the question does not say "only chose the minimal variant". In fact, I have even heard people say it is good practice to link different constructors, so that they do not duplicate code used in another one already. If the exam has questions like this, are such things marked false?
The question here is, At which point is only one object eligible for garbage collection?

class Eco{
public static void main(String[] args){
Eco e1 = new Eco();
Eco e2 = new Eco();
Eco e3 = new Eco();
e3.e = e2;
e1.e = e3;
e2 = null;
e3 = null; //line 9
e2.e = e1; //here NullPointerException
e1 = null;
}
Eco e;
}



I am fine with the NullPointerException, but I also chose the answer "after line 9 runs". The answer in the test makes it clear that the question creators intended to create a sort of island where all three objects are chained to each other.
However the way the code is presented, the island is not complete (e2 is not successfully chained to e1). If there is no chain to e1, however, I thought that at least e2 should be eligible for garbage collection as soon as e3 is nullified (and with it the last pointer to e2). Is this wrong thinking?
As I say, I know the code would not run to the end, but "eligible for gc" in my opinion meant "no matter whether the program stops at some point".
I recently found out that you can substitute the array in the public static void main method with a var-arg(String... args). Is this a case special to the main method or can I do this in other places where an array is required?
The Self-Test Answers here state that

"Has-a relationships always rely on instance variables" is correct.

Does this mean that in the exam I have to count static (class) variables as instance variables?
[ August 31, 2008: Message edited by: Kat Freudenkinder ]
I came across a question where a Thread t is defined and started before a Thread s.
- Thread s calls t.join() (so the first Thread) as its first statement, afterwards it alternates between sleeping and printing some sequence (for loop).

- Thread t goes to sleep as his first statement, then prints out something and then alternates between sleeping and printing for some time (for loop)

To my knowledge, in this situation there's no guarantee that t will be running when s invokes t.join(), as the start sequence seems not to guarantee an order of execution. In this case, would s start anyway?

Moreover, in the Bates/Sierra book, it is stated that sleep actually helps threads taking turns - i.e. the other one could jump in while the first one sleeps.

In spite of all this, the solution to this question (LearnKey master exam) says that the order of printouts is ordered: first the ones from thread t, then the ones from thread s.
Am I missing something here?
Unfortunately, I am wholly on Trey's side: the Master Exams from LearnKey for Java 5.0 ARE useless. I have been working in E-Learning for three years (not in Java certification though - so no personal interest) and believe me, this software is really not state of the art, not even according what was state of the art three years ago.
The problem is, the exam neither gives you a detailed summary on which areas you have to train (only a summary with all questions lumped into a file which is not even pdf) nor lets you archive the questions with the answer variants given during the test (those are eliminated from the saved report file, only the correct ones are given).

Moreover, the hints in the open book are really not very useful and not designed with an educational aspect in mind ("Don't confuse those terms!" as a hint for OO concept question).

Some Reference chapters are plainly taken from an older version, they sometimes talk about statements that are simply not written under the letter they say they are. The grading seems to be correct, though.

Personally, I see no way around that lousy LearnKey software because the level seems to be most accurate to what you actually get (Whizlabs apparently is a bit beyond what you have to expect, Marcus Green's TigerTamer quizzes (which I like) are probably a bit easier. LearnKey just makes your studying environment complicater than necessary - as if the learning matter alone wasn't already complicated enough.