Tim Bant

Ranch Hand
+ Follow
since May 18, 2024
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Tim Bant

Hi all and Happy New Year!

I wanted to ask a quick q regarding string pools. I understand the concept of it however when testing my knowledge on the SE17, I came across the following snippet:



My question is, since String pools are related to compile time values, is += operation considered a runtime operation, whereas a simple concatenation of say:



is considered compile time (and would ultimately return == on line 14 if applied correctly)?

Just trying to clarify for myself why 14 is considering it as false.

Thanks
2 weeks ago
Understood, will bear that in mind for my re-take. Thanks!
1 month ago
What's the "answer" / recommendation in that scenario then if undefined isn't an answer? Thanks
1 month ago
Makes sense, thanks for clarifying for me!
2 months ago
Cheers - I wonder if this could be one of those, however, whereby they changed the constraint slightly in later versions, for example, this page here (https://docs.oracle.com/en/java/javase/17/language/switch-expressions-and-statements.html#GUID-BA4F63E3-4823-43C6-A5F3-BAA4A2EF3ADC) under Exhaustiveness, you'll see it says it must have a yield when using {}
2 months ago
Hi there, I've been taking some mock questions re Java 17.

I noticed this snippet:



Where it says //redundant but allowed, shouldn't there be a yield statement since its using {} ? Or is it that because it isn't returning a value, this is permitted?

Thanks
2 months ago
Thanks Carey, trying to study for the exam so saw this example and couldn't quite work it out
2 months ago
If a line of code has an explicit cast, then does the cast happen before or after the arithmetic?

For example (I know this doesn't compile, but trying to understand why...)





I believe the cast happens first? Using the example above, fruit is casted to an int, however, we are then trying to add a float to an int, which the compiler doesn't like...? Or is it that float is bigger than a long when dealing with promotion?
2 months ago
Morning,

why doesn't the add line here work?



I would have thought since Integer extends Number it should allow it?

Thanks as always
2 months ago
ah, got you - so that explains now why, if I add a return to the new Exception, it compiles



so my understanding is that the "throw" in the below is an equivalent to a return in this scenario, would that be fair?

Hi all,
Why is the code below an acceptable Callable command?



I get why this is one here is, because its returning an Exception object:



Interestingly, the first example won't work without brackets, so it makes me a little more confused...any ideas?

Thanks
ah, that makes total sense, thanks Mike
2 months ago
Hi all,

I've been doing some practice tests on streams. One of the questions had the following:



And its explanation was that the output is not 100% guaranteed to be 3 4 or 4 3. Why is that? I thought when it came to parallel streams the output can vary.

Thanks
2 months ago
Hi (Oi) Joao,

I had this thought before I started studying - however, I went down the book route OCP Oracle Certified Professional Java SE 17 Developer Study Guide by Scott Selikoff, Jeanne Boyarsky and use the internet for further /deeper queries. I have my exam in a few weeks time - it certainly feels like I have been studying for way more than 35 hours that is for sure...