Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: brain bench question

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default brain bench question

    Sample Code
    int a = 3; int b = 0;
    switch (a) {
    case 1: b = a + 2;
    case 2: b = a + 3;
    case 3: b = a + 4;
    case 4: b = a + 5;
    case 5: b = a + 6;
    default:
    b = a * 2;
    }
    // Line A
    What is the value of "b" when the execution of the above code reaches Line A?
    Choice 1 0
    Choice 2 6
    Choice 3 7
    Choice 4 8
    Choice 5 14


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,684
    Thanks
    25
    Thanked 333 Times in 309 Posts

    Default Re: brain bench question

    We aren't going to do it for you, but I'll give you a clue: google switch fall-through
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. brain bench question
    By soumya186 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 8th, 2014, 01:50 PM
  2. brain bench question
    By soumya186 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 8th, 2014, 01:48 PM
  3. Replies: 1
    Last Post: November 4th, 2013, 04:38 AM
  4. Iterators and lists and oh god my brain hurts!
    By Brodie337 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 8th, 2011, 04:44 PM