 # The bug in the following program is in line ___. (line numbers are ...

## Question

The bug in the following program is in line ___. (line numbers are in parenthesis)
1) for (next = 0; next <= 10; next = next + 2);
2) {
3) sum = sum + next;
4) System.out.println("Sum now is " + sum);
5) }

Question 2
How many times is the println statement executed?
int i;
int j;
for (i = 0; i < 10; i++)
for (j = 0; j < i; j++)
System.out.println(i * j);

Question 3
How many elements are in array: double[] list = new double?

Question 4
What is the value in count after the following loop is executed?
int count = 0;
do
{
System.out.println("Welcome to Java");
}while (count++ < 9);
System.out.println(count);

Question 5
How many times will the following code print "Welcome to Java"?
int count = 0;
while (count < 10)
{
System.out.println("Welcome to Java");
count++;
}

Question 6
How many times will the following code print "Welcome to Java"?
int count = 0;
do
{
System.out.println("Welcome to Java");
count++;
}while(count < 10);

Question 7
How many times will the following code print "Welcome to Java"?
int count = 0;
while (count++ < 10)
{
System.out.println("Welcome to Java");
}

Question 8
How many times will the following code print "Welcome to Java"?
int count = 0;
do
{
System.out.println("Welcome to Java");
}while (++count < 10);

Question 9
How many times will the following code print "Welcome to Java"?
int count = 0;
do
{
System.out.println("Welcome to Java");
}while (count++ < 10);

Question 10
Which of the following loops prints "Welcome to Java" 10 times?
A:
for(int count = 1; count <= 10;count++)
{
System.out.println("Welcome to Java");
}
B:
for (int count = 0; count < 10; count++)
{
System.out.println("Welcome to Java");
}
C:
for(int count = 1; count < 10; count++)
{
System.out.println("Welcome to Java");
}
D:
for (int count = 0; count <= 10; count++)
{
System.out.println("Welcome to Java");
}

Question 11
If you declare an array: double[] list = {3.4, 2.0, 3.5, 5.5}, the highest index in array list is __________.

Question 12
If you declare an array: double[] list = {3.4, 2.0, 3.5, 5.5}, list is ________.

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

1. Answer: 1). Line 1. The first line of the For statement had a semicolon which is not valid
2. Answer: 45 times. While going through the first For loop starting I with 0 and as long as it is less than 10 with postfix (meaning after) increment. Then, the second For loop using j with the same incrementing if variable i is less than j will multiply i by j with it printed out.
Output:
0
0
2
0
3
6...

By purchasing this solution you'll be able to access the following files:
Solution.docx.

\$15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available IT Technical Support Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.