Results 1 to 3 of 3
  1. #1
    mislablum is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default flow control - boolean

    Im studying to do Java Standard exam, but I cant understand well the following question:

    Given:

    1. class MoreAsserts {
    2. static int x=5; //I understand that the x value can't be reassigned. That's right?
    3. public static void main (String [] args) {
    4. assert (doStuff(42)); //I did find the usage of this keyword assert
    5. if(x < 40);
    6. else assert (false);
    7. }
    8. public static boolean doStuff(int arg) { //I don't undertand the sentence (ing arg)
    9. assert(arg < x++);
    10. return false;
    11. }
    12. }

    And the command-line invocation:

    java -ea MoreAsserts

    Which is true?

    A. An assertion error is thrown
    B. An assertion exception is thrown
    C. The command-line invocation is invalid
    D. The code runs with no error and no output

    Everone may you help me, please? I have some manuals of Java like Thinking in Java and How to program in Java but I can't fine where is this subject. I would thankful any help.

    Mercedes

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,864
    Rep Power
    8

    Default Re: flow control - boolean

    What are you confused about? What do you think is the answer? What happened when you wrote a little example program to test your assumptions?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    mislablum is offline Member
    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Default Re: flow control - boolean

    Quote Originally Posted by KevinWorkman View Post
    What are you confused about? What do you think is the answer? What happened when you wrote a little example program to test your assumptions?
    Sorry, after to post it I found in the last manual bought to prepare my Java exam the issue. I realized that I don't understand because I need to read the chapter about handling exceptions. Thanks anyway.

Similar Threads

  1. Replies: 3
    Last Post: 09-13-2011, 12:01 AM
  2. boolean error help when no boolean is given
    By drewtrcy in forum New To Java
    Replies: 18
    Last Post: 05-05-2011, 09:04 AM
  3. Control flow operators
    By davetheant in forum New To Java
    Replies: 5
    Last Post: 01-18-2011, 04:15 AM
  4. How to generate Data Flow Diagram(Work Flow Diagram)
    By stsivaraj in forum AWT / Swing
    Replies: 1
    Last Post: 12-22-2010, 11:21 PM
  5. control app width based on certain control
    By thebillybobjr in forum SWT / JFace
    Replies: 0
    Last Post: 05-15-2008, 04:52 PM

Posting Permissions

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