The default block since the grade doesn't match to any of the choices. you
can think on the switch-case as if else if.
so it will look like:
if (grade == 100) System.out.println( "Excellent!" );
else if (grade == 90) System.out.println("Good job!" );
else System.out.println("Sorry, you failed.");
BR,
Yaron
On Mon, Jun 29, 2009 at 11:39 PM, 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
-~----------~----~----~----~------~----~------~--~---