Hi, The sentence that will be executed will be the default. Why? because you used the switch statement. Switch compares the the value of grade with the specific cases you've declared inside. Use the if statement instead if you want a better comparison with, your case at least.
Jay On Tue, Jun 30, 2009 at 4:39 AM, Luis Eduardo Coca <[email protected]>wrote: > In JEDI Course Notes, on page 114, which sentence will be executed? The > default block? Please explain what is going on here. > > > public class Grade > > { > > public static void main( String[] args ) > > { > > int grade = 92; > > switch(grade){ > > case 100: > > System.out.println( "Excellent!" ); > > break; > > case 90: > > System.out.println("Good job!" ); > > break; > > case 80: > > System.out.println("Study harder!" ); > > break; > > default: > > System.out.println("Sorry, you failed."); > > } > > } > > } > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
