Yes, you are right, the default block will be executed:

 

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.");

                                                // break;

                                }

                }

}

 

Output: 

======

Sorry, you failed.

 

What seems to be the problem??

 

Jacques Colmenero

Solution architect

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Luis
Eduardo Coca
Sent: June 29, 2009 4:39 PM
To: [email protected]
Subject: [java programming] Mistake in JEDI Course Notes?

 

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.");

}

}

}



Checked by AVG - www.avg.com
Version: 8.5.375 / Virus Database: 270.13.0/2209 - Release Date: 06/29/09
14:43:00


--~--~---------~--~----~------------~-------~--~----~
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