Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Tami Wakana

Greenhorn
+ Follow
since Jul 25, 2016
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
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tami Wakana



The question asks what does the output of the code contain and the answer is "abce" and "An exception with the message set to "3"". I understand the exception with the message set to "3", but I don't understand why the output is just abce. Shouldn't it include "d" since line 8 throws a RuntimeException and there is a catch block that takes in a RuntimeException?
For switch statements, I understand enum constants are allowed




I understand why they all don't compile. I'm wondering what an enum constant would look like (the last one doesn't compile because it is an enum value, not a constant)

[edited to fixed code tags]
Hey Roel De Nijs,

Thank you for replying!! It clarified a lot! The lambda is just another way to write a Climb object I guess, and I didn't catch that at all

I think for your pop quiz, it shouldn't compile because the interface takes in and 2 ints, not a StringBuilder and an int! Now I understand where the explanation is coming from

Thanks so much!
I'm a bit confused on the explanation of the answer
The code is



There is a compiler error on line 7 and the explanation states that it is because h is a StringBuilder and the interface method takes in two ints.
I understand that, but the check method takes in Climb climb, not an int. Can someone clarify this further for me?