Flow Control Java Challenge

flow control

Flow control is a basic Java feature but it can be tricky too. Do you think you can get the following Java Challenge right?

It's time to improve your Java skills with this Flow Control Challenge

Flow Control Challenge

When running the following code, what will be the output?

flow control

 

If you want to watch the FULL video explanation check it out at the following link:

Keep breaking you limits and doing your best!

Written by
Rafael del Nero
Join the discussion

2 comments
  • The default boolean value in java is false. Therefore ishomerfat default value is false when we check the first condition it has to fail I think. You said that we set the ishomerfat variable to true. How is that?. We are checking the condition in the first if condition block. We are not assigning the ishomerfat value to true. Correct me if I am wrong.

    • isHomerFat = true is not a comparison, but an assignment, so after that isHomerFat will be true. In Java an assignment have a return value, so the if statment evaluates it as true.

Stand Out as a Java Developer and Get Your Dream Job!

You will get the book by email in a few minutes after registering.