Maor Pau

Greenhorn
+ Follow
since Jan 12, 2017
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
17
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Maor Pau

from OCA OCP Java SE 7 Programmer I & II Study Guide (Oracle Press Practice Exam Software)
I saw this question from OCA/OCP Java SE 7 Programmer I & II Study Guide by Kathy Sierra



Until now, All the questions I've seen this kind clearly note that every class in A separate file.
I thought that there is a compile time error because two public classes in the same file and also two package statements.

Oracle exam topics wrote:No file or directory path names for classes: If a question does not state the file names or directory locations of classes, then assume one of the following, whichever will enable the code to compile and run:
All classes are in one file
Each class is contained in a separate file, and all files are in one directory



there are such questions like this?
thanks

Henry Wong wrote:
The last part of the definition is the relevant part (I still find it amazing that this is that well hidden in the specification). To be a variable that is a compile time constant, the variable needs to be...

  • declared as final
  • have a primative or String type
  • initialized (on the same line as the declaration)
  • assigned to a compile time constant expression

  • Did you mean one of the options or all of them?
    it can be final but not initialized (on the same line as the declaration)?
    7 years ago
    My question is, static variable b1 in the Alpha class cannot be eligible for garbage collection while the class is loaded
    even though there is no reference available to a1, b1 and b1 (from outside).

    btw this question took from OCA/OCP Java SE 7 Programmer I & II Study Guide by Kathy Sierra

    Jeanne Boyarsky wrote:
    Does that mean you are good now? Or that those posts didn't answer your question?


    Still did not understand  
    hi,
    I came across this question:


    When line 18 is reached, how many objects will be eligible for garbage collection?


    I can not understand how only 1 object is  eligible for garbage collection.
    a1, b1 and b1 is set to null. then a2 still pointing to his object, and have a b2 reference pointing to b2 object.
    so a1, b1 and b1 are unreachable and should be eligible for garbage collection?

    (also I add an image for example, please correct me if there is a mistake)

    Thanks

    Henry Wong wrote:
    The Java Language Specification, Section 5.3, allows for unboxing followed by widening -- so, the method (marked via //3) will be called.

    Henry


    thanks!
    can I ask what is the reason I cannot  do like:

    but this one will work:
    Hi,
    I understand that widening gets more priority over autoboxing and var-args,
    and that is not possible to do widening and then boxing, but boxing and then widening is possible.
    But what's happened when you try to pass Integer and there is only long or Long?
    First, at line 19 autoboxing has made, then at line 10 unboxing?

    Thanks!

    also english isn't my native language..
    thanks
    is it because of the ternary is written wrong ?