Claire Chan

Ranch Hand
+ Follow
since Nov 21, 2013
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Claire Chan




Can anyone please explain to me why above code output is

Hello, StringObject@<hascode>
Hello, World

I understand StringBuilder value but not value from StringObject

Thanks



Thanks, Roel and Jesper. Now I get what the book says. Thank you for the clarification.
Reading OCA study guide for my exam. I'm confused what it says about Return Type.

The book says "When returning a value, it needs to be assignable to the return type." with below example.



It suggests not to return the value directly as below :



However, it doesn't mean we can't return the value directly. Is it because of performance? or any other reason?

Thanks
Hi,

I'm planning to take OCA exam end of August. I'm reading OCA Java SE 8 Programmer I by Jeanne Boyarsky and Scott Selikoff. However, I foud there are still recommend books by people. My question is if it would enough just to read this one book and practice mock exams from enthuware? or I still have to read other books?

Thanks



I understand that only literal values goes to String pool and those strings not in the String pool are garbage collected. Based on above code, "" becomes eligible for garbage collection. Then again, "ab" is assigned to alpha and "a" becomes eligible for garbage collection. Since "ab" is literal, why it doesn't go to String pool and become eligible for garbage collection?

that really clarifies my doubt for putting parenthesis for two values. Thanks Charles
I understand that we don't need to cast explicitly into another data type by using compound assignment operators in some cases. I want to know which way can provide better performance? or their performance levels are same?

For eg,



regarding to line 4 and 5, which line provides better performance?

thanks
yes but I wonder why we need to put x*y inside parenthesis like (x*y). For eg,

int x = 1

short y = (short) x; // we don't need to put x inside parenthesis like previous example.
I need some clarification about numeric promotional rules. example as below :



can someone explain me why line 3 is not compiled. I think there is nothing wrong with it as I casted data types to short. Why i need to put x*y inside parenthesis?

Thanks

ah i see. I thought I must import both classes.
thanks Stephan.
As it doesn't import class from aquarium.jellies package, why A is correct
Hi,

based on the explanation about garbage collection and using finalize() method. I think I understand but when I do practice test, I don't fully understand what the book is trying to say between system.gc() and finalize(). I think I need more practice on that topic. Where can I get resource or practice test about this apart from OCA SE8 Study Guide by Scott & Jeanne.

Thanks
2 years ago
Hi,

I'm preparing to take OCA exam in June. I'm reading OCA Java SE 8 Study Guide. There's one question I need clarification for "import" keyword. Exam number 7 for chap 1. Question is as below :

Given the following classes, which of the following snippets can be inserted in place of
INSERT IMPORTS HERE and have the code compile? (Choose all that apply)



A. import aquarium.*;
B. import aquarium.Water;
   import aquarium.jellies.*;
C. import aquarium.*;
   import aquarium.jellies.Water;
D. import aquarium.*;
   import aquarium.jellies.*;
E. import aquarium.Water;
   import aquarium.jellies.Water;
F. None of these imports can make the code compile.



Correct answers are : A,B,C

I understand why B & C are correct. However, I'm confused about being A is correct. There are two same class under different package. One inside "aquarium" package. Another one is "aquarium/jellies" package. importing using "import aquarium.*" doesn't make java to confuse which class from which package to import?

Thanks
2 years ago
what about those reports end with txt?