Justyna Wozniak

Greenhorn
+ Follow
since Oct 04, 2006
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 Justyna Wozniak

Hello,
this question is based on K&B, page 302, Q3.
Why does the following piece of code compile:

?
Does x get unboxed to a long and then converted to a float?
Or is x.floatValue() called?

Thanks,
Justyna W.
So why is it only safe to add Strings to a List<? super String> ?

Thanks,
Justyna W.
Hi,
in the Masterexam there's a question about the benefits encapsulation and one of the answers is that it results in better testing and higher reliability. How exactly does encapsulation result in these?

Thanks,
Justyna W.
Hello,
numeric values cannot be assigned to booleans in Java (e.g. boolean b = 100; gives an "incompatible types" compiler error).
Why then does this piece of code compile fine and print true:

?

Thanks,
Justyna W.
Hi,
I found this trail:
You can find there this piece of code:

Which produces:

So obviously there is a loss of precision.
Now what I don't understand is why there is no loss of precision for this piece of code:

as it produces:


Thanks,
Justyna W.
Hello,
I found this question in JQPlus:



Which of the following options are valid?
...
c) i.equals(d);
d) d.equals(ln);
e) ln.equals(42);



The answer pointed by the mock exam is that c) and d) are correct, and e) isn't ().
I looked at the forum archives and also tested the code myself, and it looks like the primitive 42 is converted to an Int when it's apssed as a parameter to the equals() method. So shouldn't the correct answers be: c), d) and e) (even though they all actually return false)?

Thanks,
Justyna W.
Yes, I meant this type of questions, or even more specifically something like com.enthuware.ets.scjp.v5.2.563 (as I know that D'n'D questions will definitely appear in the exam).

Thanks,
Justyna W.
Hello,
in the JQPlus mock exam, there are questions where the user has to type in the whole answer (type in a piece of code) - do questions of this type appear in the actual exam?

Thanks,
Justyna W.
Hello,
I am trying to find out why the following piece of code:


displays this output:



If the default number of fraction digits is 3, why is .5668 truncated to .57?
And why does the code display .5703 when the number of fraction digits is extended to 4?

Thanks,
Justyna W.
Hello,
this question comes from JQPlus:

Consider the following two java files in /home/user directory:

//file A.java

package com.enthu;

class A

{

}



//file B.java

package com.foo;

class B

{

}



The files are compiled using the following command line:



javac -d /home *.java



Where will the class files go?


The answer they give is:
"A.class in /home/com/enthu and B.class in /home/com/foo"

but I don't see why the A.java and B.java files are supposed to be visible to the compiler as the path is set to /home and not /home/user ?

Thanks,
Justyna Wozniak
Hello,
I am wondering why this piece o code:

seems never to cause thread b to get access to the run method.
The output is following:

and there's never any output from thread b.

Thanks,
Justyna Wozniak
Hi,
I am wondering on what theoretical basis this code:

produces the following output:

Why doesn't it produce:

?
Hi,
I found this in the JQPlus mock exam:

could you please explain to me why this piece of code:


changes the -2222 to -2,222? (or o be precise it prints out "-2,222")?

K & B book says the comma causes the usage of locale-specific grouping operators, but why is the comma added after the first 2?

Thanks,
Justyna
Hello,
here's the code sample:

I do understand why an inner class within a static method has access to all static methods of the encapsulating class, but I don't understand why it also has access to all final authomatic variables within the encapsulating method (and no access to non-final authomatic variable in that method).
Does it also have any access to any other final variables in that class?

Thanks in advance,
Justyna W.
[ October 14, 2006: Message edited by: Barry Gaunt ]