Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

40. Consider the program below: public class Test { public static void main(String[] args) { Int[] a; a = new int[10]; for(int i = 0;

40. Consider the program below:

public class Test

{

public static void main(String[] args)

{

Int[] a;

a = new int[10];

for(int i = 0; i < a.length; i++)

a[i] = i + 2;

int result = 0;

for(inti = 0; i < a.length; i++)

result += a[i];

System.out.printf(Result is: %d%n, result);

}

}

The output of this program is:

a. 62

b. 64

c. 65

d. 67

44. Assume array items contain the integer values 0, 2, 4, 6, and 8. Which of the following uses the enhanced for loop to display each value in array items?

a. for(int i = 0 : items.length)

System.out.printf("%dn%, items[i]);

b. for(inti : items) System.out.printf(%d%n, i);

c. for(int i: items) System.out.printf(%d%n, items[i]);

d. for(int i = 0; i < items.length; i++)

System.out.printf("%dn%, items[i]);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

List the major prohibitions of the Canadian Human Rights Act .

Answered: 1 week ago