Win a copy of Terraform in Action this week in the Cloud forum!

Sylvain Bouchard

Ranch Hand
+ Follow
since Dec 06, 2005
Sylvain likes ...
Java ME Spring Objective C
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 Sylvain Bouchard

Hi,

Congrats my friend, welcome to the club ;o)
Great score by the way

10 years ago
Thanks to you all
these forums have really helped me a lot making a difference
10 years ago
Hi Rancher,

As always it was a pleasure to study with all of you !!
Cleared my OCPJP java 6 with 93% !!!

Good luck to all of you !
10 years ago
Deepak is right !

Or if you don't want to use the -jar option, you need to provide the full qualified class name like this:

java -cp classes.jar com.de.tester.Testclass
Widening primitive conversions do not lose information about the overall magnitude of a numeric value.
Indeed, conversions from an integral type to another integral type do not lose any information at all; the numeric value is preserved exactly.

however, an assignation to a float may lose information about the overall magnitude of the converted value in a non strctfp environment !
float and double are two special case.

You can read more about it, from this documentation
http://java.sun.com/docs/books/jls/third_edition/html/conversions.html
Hi Micha,

This assignment works cause the value 12 is small enough to be hold by a short.
Remember that a short can hold a value from -32768 à 32767.

If you use a value directly, and not a variable to variable assignment like your second example,
the compiler will permit the assignation without complaining.

So this will work
short s1 = 32767; // Max value for a short

But this will cause the same compiling error as your others example:
short s1 = 32768; // out of range for a short

Test.java:8: possible loss of precision
found : int
required: short


Wouter is right, it can be both.

This code output:
ii is an Object
ii is an Object[]
ii[0] is an Object




Thank you Paul, for your help!
I got the picture and will surely score higher in this objective !
I see your point ! You're absolutely right.
I think in terms of variables, when I should think object "creation"

Object Reference
A ---> objA
---> objectA

B ---> objectB

--------------------------------------
2 Objects candidate to be GC
Sorry, I've misused the word GC, I meant "candidate for GC" !

For the three object:
- objA in the main function
- objectB attribute in Class A
- objectA attribute in Class B, which is the same reference as the object in the main function

Three object, two references...

So, If i get back to my original question and your explanation: all objects will be candidate for GC.
Hi Paul,

So you're saying All three objects (two references) will be GC ?
I got 82%, I'm ok with my score...
I'm currently reworking my weakness and continue to prepare for the version 6 in two weeks !!


Hi Ranchers,

I came across code at work, and I try to figured it out how the garbage collector will handle this case.
In fact, it looks like a goof tricky question for the exam !

Object A have an attribute Object B
Object B have an attribute Object A





objA will obviously be eligible for GC !
But what about objectB and objectA? They still reference each other.

I'm tempted to say that they will not be GC !!

What do you think?

Sylvain
Hi, I have just passed the OCPJP 5 exam, with score 82%.

Thank you all for making this community awesome.

Good luck to all.

Best regards,

Sylvain bouchard
10 years ago
Hi JavaRancher,

thanks for this community, I've just cleared my OCJP (Java 5)!
Didn't really get involve yet, but reading the daily posts, help me make the difference !