Hi Luis,

In this program the statement given under the default section will be
executed. So it will print "Sorry, you failed." When the program begins it's
execution, the variable named *grade* which is an integer is assigned the
value *92*. After the initialization, the switch case construct is
encountered. Here a matching case with the label 92 is searched. Since there
is no label with the value 92, the statement in the default label is
executed and thus "Sorry, you failed." gets printed.

Thanks & Regards,
Babu

On Tue, Jun 30, 2009 at 2:09 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to