Cookie Consent by Free Privacy Policy Generator Computer Science: Programming with a Purpose Week 3 Quiz Answers - Coursera!

The basis for education in the last millennium was “reading, writing, and arithmetic;” now it is reading, writing, and computing. Learning to program is an essential part of the education of every student, not just in the sciences and engineering, but in the arts, social sciences, and humanities, as well. Beyond direct applications, it is the first step in understanding the nature of computer science’s undeniable impact on the modern world. 

This course covers the first half of our book Computer Science: An Interdisciplinary Approach (the second half is covered in our Coursera course Computer Science: Algorithms, Theory, and Machines). 

Our intent is to teach programming to those who need or want to learn it, in a scientific context. 

You can enroll here:


Computer Science: Programming with a Purpose Week 3 Quiz Answers - Coursera!

Coursera Computer Science: Programming with a Purpose Week 3 Quiz Answers!

Arrays

Question 1) Which statements apply to one-dimensional arrays? Mark all that apply.

They facilitate storage and manipulation of data
With an index, a program can instantly access a given value
Efficiency derives from low-level computer hardware organization
Safe to think of values as being stored in contiguous locations in memory
They enable storage of large amounts of data (values all of the same type)
They enable programmers to mix different types of data in the same data structure

Question 2) Which statements initialize the values in an array? Mark all that apply.

double[] a;
double[] a = { 0.3, 0.6, 0.1 };
a.length = 10;
double[] a = new double[100];
a = new double[1000);

Question 3) What does the following code fragment print?

int[] b - { 1, 2, 3};
int[] c = b;
c[0]+= b[2];
c[1]+ =b[1];
c[2]+ =b[0];
System.out.println (c[0] + c[1] + c[21]):

Answer: 15

Question 4) What does the following code fragment print?

int[] a = new int[10];

for (inti = - 0; i <10; i++)
      a[i] = 9 i;

for (int i = 0; i < 10; i++)
      a[i] a[a[i]];

System.out.println(a[5]) ;

Answer: 4

Question 5) Which of the following statements are true for Java arrays? Mark all that apply.

If a and b are one-dimensional arrays of the same length, then the assignment statement a = b; copies each element from b to the corresponding position in a
Creating a one-dimensional array of length n takes time proportional to n
Two-dimensional arrays are rectangular (all rows have the same number of elements and all columns have the same number of elements)
Creating a one-dimensional array of length n will also initialize the n elements
It is possible to create a one-dimensional array such that one element is of type int and another is of type String.
Array indices start at 1.

Post a Comment

Previous Post Next Post