Results 1 to 7 of 7

Thread: What is default switch case ?

  1. #1

  2. #2
    Thoughtgrid Thoughtgrid's Avatar
    Join Date
    Jul 2016
    Location
    Bangalore
    Posts
    219
    The case statement and default statement can occur in any order of the switch statement this clause is an optional clause that is matched none of the constants in the case statement can be matched.

  3. #3
    The default clause is an optional clause that is matched if none of the constants in the case statements can be matched.

  4. #4
    Registered
    Join Date
    Nov 2016
    Posts
    134
    The switch and case keywords evaluate expression and execute any statement associated with constant expression whose value matches the initial expression.

  5. #5

  6. #6
    Registered pxljobs's Avatar
    Join Date
    Jul 2016
    Location
    Bangalore
    Posts
    290
    The switch statement is n selection control mechanism used to allow the value of the variable.

  7. #7
    Registered
    Join Date
    Feb 2017
    Posts
    10
    In a switch statement, default case is executed when no other switch condition matches. Default case is an optional case .
    It can be declared only once all other switch cases have been coded.
    In the below example, when score is not 1 or 2, default case is used.

    Code:
    public class switchExample {
    int score=4;
    public static void main(String args[]) {
    switch (score) {
    case 1:
    System.out.println("Score is 1");
    break;
    case 2:
    system.out.println("Score is 2");
    break;
    default:
    System.out.println("Default Case");
    }
     
    }
     
    }

Similar Threads

  1. The Case Against Link Exchanges
    By Chris in forum Recent Blog Posts
    Replies: 0
    Last Post: 05-13-2008, 07:35 AM
  2. Anyone here been a google case study?
    By Emancipator in forum Advertising & Affiliate Programs
    Replies: 10
    Last Post: 03-10-2007, 08:02 PM
  3. Case Studies
    By Chris in forum Site and Forum Feedback
    Replies: 16
    Last Post: 02-18-2007, 05:29 PM
  4. Switch over to WireNine.com Web hosting today!
    By WireNine.com in forum The Marketplace
    Replies: 0
    Last Post: 06-21-2006, 07:43 AM
  5. Don't switch to yahoo domains
    By Masetek in forum Domain Names
    Replies: 8
    Last Post: 12-03-2005, 04:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •