JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SO EASY FO...

50.1K

Verified Solution

Question

Programming

JAVA / I KNOW THERE IS MORE THAN ONE QUESTION BUT THEY ARE SOEASY FO YOU I NEED YOUR HELP PLEASE HELP ME. I WILL GIVE UPVOTE ANDGOOD COMMENT THANK YOU SO MUCH !!!

QUESTION 1

  1. Consider the following program segment:

    int i = 2;
    int n = 18;

    while (i < n)
    {
        if ((i % 2) == 0)
    i++;
    else
    n--;
    }
    System.out.println( i );

    What is the value of n when the above program segment is doneexecuting?

    A.

    n is: 18.

    B.

    n is: 3.

    C.

    Infinite Loop. i will not change.

    D.

    No Output.

QUESTION 2

  1. Consider the following program segment:

    int i = 2;
    int n = 18;

    while (i < n)
    {
        if ((i % 2) == 0)
    i++;
    else
    n--;
    }
    System.out.println( i );

    What is the output of the above program segment?

    A.

    There is no output.

    B.

    The output is 2.

    C.

    The output is 18.

    D.

    The output is 3.

QUESTION 3

  1. Consider the following program segment:

    int i = 1;
    int n = 10;

    while (i < n)
    {
        if ((i % 2) != 0)
    i++;
    }
    System.out.println ( i );

    And what are the values of i and n after execution?

    A.

    i will be 11. n will be 10.

    B.

    i will be 11. n will be 1.

    C.

    Infinite Loop: i is stuck at 2 and n stays at 10.

    D.

    No Output

QUESTION 4

  1. Consider the following section of code:

    int i = 1;
    int j = 3;
    while (i < 15 && j < 20)
    {
    i++;
    j += 2;
    }
    System.out.println (i + j);

    And what are the values of i and j after execution?

    A.

    i = 10, j = 21

    B.

    i = 11, j = 22

    C.

    i = 15, j = 20

    D.

    i = 16, j = 21

QUESTION 5

  1. Consider the following section of code:

    int i = 1;
    int j = 3;
    while (i < 15 && j < 20)
    {
    i++;
    j += 2;
    }
    System.out.println (i + j);

    What is the output of the above program segment?

    A.

    The output will be 31.

    B.

    The output will be 33.

    C.

    The output will be 34.

    D.

    The output will be 35.

QUESTION 6

  1. Consider the following section of code:

    int x = 10;
    do
    {
       System.out.println( x );
    x -= 3;
    }
    while (x > 0);

    And what is the value of x after execution?

    A.

    The value of x after loop is done = -1.

    B.

    The value of x after loop is done = -2.

    C.

    The value of x after loop is done = 1.

    D.

    The value of x after loop is done = 2.

QUESTION 7

  1. Consider the following section of code:

    int x = 10;
    do
    {
       System.out.println( x );
    x -= 3;
    }
    while (x > 0);

    What is the output of the following program segment?

    A.

    -2

    B.

    10 9 8 7 6 5 4 3 2 1

    C.

    1 4 7 10

    D.

    10

    7

    4

    1

QUESTION 8

  1. Consider the following section of code:

    int i = 1;
    int n = 0;
    while (i <= n)
    {
    System.out.print( i );
    i++;
    }

    And what are the values of i and n after execution?

    A.

    i = 1 and n = 0.

    B.

    i = 2 and n = 0.

    C.

    i = 0 and n = 0.

    D.

    i = -1 and n = 0.

QUESTION 9

  1. Consider the following section of code:

    int i = 1;
    int n = 0;
    while (i <= n)
    {
    System.out.print( i );
    i++;
    }

    What is the output of the following program segment?

    A.

    1, 2, 3, ...

    B.

    1

    C.

    0

    D.

    No output.

Answer & Explanation Solved by verified expert
3.7 Ratings (585 Votes)
    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students