Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how types affect execution, part 3 = 0 Here is the same program one more time, again with different starting values for the data list.

image text in transcribed
image text in transcribed
how types affect execution, part 3 = 0 Here is the same program one more time, again with different starting values for the data list. # assume Python 2 data = [ "1", "2", "3" ] total = 0 average n = 0 for value in data: n += 1 total += value average total print "average:", average Now what averages are printed? 1, 1.5, 2 "1","1.5", "2" 1,6,41 error before the program starts error while the program is running snapshot diagrams and final Suppose we want to add final to both variable declarations in the hailstoneSequence method, as shown: public static List haiistone Sequence(final int n) list = new ArrayList(); while (n = 1) { list.add(n); if (n%2 == 0){ n = n/2; } else { n- 3* n + 1; > } list.add(n); return list; } Which of the following are true statements about putting final on n? final can't be used on n because n is a parameter of a method final can't be used on n because its type is int and int is already immutable final can't be used on n because n is reassigned to other integer values in the body of the method final can be used on n, and it prevents n from being reassigned Which of the following are true statements about putting final on list ? final can't be used on list because list is a local variable final can't be used on list because its type is List and List is a mutable type final can't be used on list because list.add() is used to change the list in the body of the method final can be used on list, and it prevents the list variable from being reassigned

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

Explain the market segmentation.

Answered: 1 week ago

Question

Mention the bases on which consumer market can be segmented.

Answered: 1 week ago