Win a copy of Head First Android this week in the Android forum!

Chai Stof

+ Follow
since Feb 04, 2017
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chai Stof

Thanks Roel,

I guess in this case it wouldn't be much more verbose to choose a bit more exact wording, but then again it is much more important to be well prepared and aware of the fact that some questions will be like this. I had already found that topic, indeed interesting!

Now I should go and study, instead of hanging around on the forum
I actually found out about that next, but I didn't want to post another "duh ! "

But thank you for the explanation!
Ow pfff.... I tried something that I did not expect to work... but apparently you can cast an object to a stringarray:

Looks kinda funny, but it works!

So nevermind folks, but thanks anyway!
Hi Folks!

Today I wanted to use the Iterator on a list of stringarrays. But it did not work out the way I expected.

I could solve it another way obviously, but as I am studying for the OCA it seems useful to understand what's happening here. So, help me out? Why does it return Object when the list contains String[]'s ?
Is there a way to solve this?

here's the code:

And the error: error: array required, but Object found

hey tof!!

Congratulations Piet!
4 years ago
HeY fun stuff!

I thought it might not compile but it does.... and after some checking and adding some code I believe I heave learned that:
As soon as execution hits a "try" it will always execute a finally (if present) EVEN before it returns, no matter where the return statement.
It will choose the last return value it finds, but it will not update dat value if it changes AFTER the return statement.

As for explanation why: No idea, it is what it is, probably it is written down somewhere as well. The reason I suspect is because in the finally you normally want something DONE FOR SURE, this way apparently that works out just fine!

Strange scenario, nice find!

Out of curiosity: What were you looking for/ testing/ trying out when you wrote this Piet? Surely not to find this obscure thing???
Good one, congratulations!
4 years ago

Henry Wong wrote:

Chai Stof wrote:But I still do not understand where in this is " a reference to a class" ?

Well, if you are being really pedantic, obviously, there is no such thing as a "reference to a class", as references are for pointing to instances. Relaxing the statement a little, you can somewhat guess that the author probably meant a "reference to an instance of a particular class type"...


Yeah I guess I am pedantic in that case. This is exactly where the confusion comes from. (You are right, the "issue is more related to understanding what is being asked")
Since everything in Java is very exact, up to capitalisation, why should I expect this to be "relaxed" suddenly?

Anyway, interpreted in this way, I understand the question. So thanks all for helping me out!

Hey Piet!

Thank you for your reply. Obviously it makes more sense to have an example that sounds logical in the IS-A test. Thanks for pointing that out again.
I also understand all the examples you put up there, no problem there. But I still do not understand where in this is " a reference to a class" ?

The answer was false by the way "A reference to a class may be automatically used as a reference to a superclass without an explicit cast." is what the card said.

Hi Mala,

thank you for your effort! I have never thought of putting questions in categories like this, but I believe it will help me get a bit better overview. And nice questions too!
Hmm.... I was writing this out  of my head just here and noticed some errors such as Class has to be class and the method name "main" is missing.

Then I tried it out in Intellij, and actually the second scenario also doesn't work.

Is there a way to edit posts here?

Anyway the question then would be: What is this question really asking ?
Hi Folks!

First of all a small introduction: My name is Chai, I am from holland and right now I am studying for the  OCA exam. I followed a course on udemy that I like and now I continue with the book of Jeanne Boyarski and Scott Selikoff.
I tried some of the flashcard questions just to get a feel of where I am at, and what to put special focus on.

Now I found this question: "Tue or False: A reference to a class may be automatically used as a reference to a subclass without an explicit cast.

What exactly si meant here?

1)  // in this case it would be true... but maybe this is a reference to an object and not to a class?


As I am writing this I begin to suspect the latter, but maybe I am overseeing something and it is a different situation all together.

Thank you for any help here, and thanks so much for the forum in general. Great stuff!