Jake Monhan

Ranch Hand
+ Follow
since May 21, 2018
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
13
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jake Monhan

I must be so busy looking at the forest that I'm not seeing the trees.

I gave a its new object to point to on line //1. Of course there would be no Exceptions on line //2!!!

Putting in line //2 without //1, throws what it supposed to do.

I was practicing casting in inheritance/class combination since I've seen them the OCA practice exam questions, and in the this code based on everything I understand about this subject, line // 2 has to cause a run time exception, because it does not point to object of class B. However, when I run it, there is no exception of any kind!

Would someone please tell me, what's up? Thanks

In the following code MyClass() object created in line //1 is set to be garbage collected after line //6. I just was wondering, the object in question still has mc pointing to it, so why doesn't that prevent it from being garbage collection eligible?



Wow, it will take me some time to answer your challenge while still preparing for the OCA exam. But given the following code snippet from your code,



Speaking very simplistically wouldn't the problems raised by w.setTemperature(1000); be solved by modify the if condition to if (degrees < 0 || degrees > 200) { }?
9 months ago
Looking at the last 3 posts, it looks like this is something to be debated for improvements(?) in java 11.
So using your code snippet as example,

by modifying Water() to achieve encapsulation by adding getWater() { // return code} & setWater (int amount) { //this. code} and setting amount and content to private, we would have invariant, wouldn't we?
10 months ago
Thank very much for taking so much time to clarify invariant.

Looking at your replies and code, can one say:

1. Encapsulation is one of the tools that can be used to guarantee invariant?
2. Encapsulation is the best tool that can be used to guarantee invariant?
3. Invariant can be achieved independent of encapsulation?
10 months ago
I'm trying to get straight/clarify in my mind as to state of invariant vs. encapsulation in order to preserve a field from changing.  Or is there some overlap between the two, in the case of keeping a field from changing by making it private while the methods are public?

Hints/Examples, please. Thanks
10 months ago
Since I originally setup Printable as an interface and others to implement it to see how they interact by passing a reference, I left them the way they were setup. But you're right, now that I see how they interact, the code has a lot of room to streamline.
Now that's what I'm talking about:)


Sorry about the indentations. When I copy the code from NetBeans it shifts around. I'll pay more attention to it.

You are correct. I was looking into overloading by passing references, and through I must admit, some trial and error I came up with passing class and reference to walk() and to be honest a bit surprised that it worked. So that's why I asked the question about the logic of how it worked.

Since you mentioned adding the print statements to the walk() to see what happens, I added more code to the main() of the Test class to make sure the print results came out the same. But, is there a good way  to consolidated all these different instantiations?

Given the following code snippet,



1. I don't understand how do the parameters work in the Walk method()?
2. If one was to access any of the walk methods from the Test class' main(), how would the code layout?

I appreciate any hints. Thanks
I've been taking practice exams from different places and questions about following subject have popped up.



I have not seen any of these in the OCA prep book.  So I was wondering if I should study these independently or are they not in the book because they are beyond the 1z0-808 exam scope? Thanks
I should have known it was some basic rule behind this:)