Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.The process of hand-tracing code is valuable because Select one: a. It is usually faster than just running the code. b. It is the best

1.The process of hand-tracing code is valuable because

Select one:

a. It is usually faster than just running the code.

b. It is the best way to design an algorithm.

c. You must already have a working program in order to do it.

d. It gives valuable insight that you do not get by running the code.

2.

Which loop does not check a condition at the beginning of the loop?

I. The do loop

II. The while loop

III. The for loop

Select one:

a. I and II

b. I and III

c. I only

d. III only

3.

In the following code snippet, when does the execution of the program switch from the inner loop to the outer loop?

int i; 
int j; 
for (i = 0; i <= 9; i++) 
{ 
 for (j = 1; j < 5; j++) 
 { 
 System.out.println("Hello"); 
 } 
} 

Select one:

a. When the value of j becomes 5

b. When the program executes completely

c. When the condition for the outer loop is met

d. When the value of i is incremented

4.How many times does the loop execute in the following code fragment?

int i; 
for (i = 0; i < 50; i = i + 4) 
{ 
 System.out.println(i); 
} 

Select one:

a. 11

b. 12

c. 13

d. 14

What will be the final output of the following code snippet when a user enters input values in the order 10, 20, 30, 40, 50, and -1?

public static void main(String[] args) 
{ 
 double sum = 0; 
 int count = 0; 
 double salary = 0; 
 double average = 0; 
 Scanner reader = new Scanner(System.in); 
 System.out.println("Enter salaries (-1 to stop): "); 
 
 while (salary != -1) 
 { 
 salary = reader.nextInt(); 
 if (salary != -1) 
 { 
 sum = sum + salary; 
 count++; 
 } 
 } 
 if (count > 0) 
 { 
 average = sum / count; 
 System.out.println("The Average Salary: " + average); 
 } 
 else 
 { 
 System.out.println ("No data!"); 
 } 
 return 0; 
} 

5. Select one:

a. The Average Salary: 0

b. The Average Salary: 30

c. The Average Salary: 24.83333

d. There will be no output as the code snippet will not compile.

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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions

Question

What areas of disclosure are required for financial instruments?

Answered: 1 week ago

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago