Computer Science: Programming with a Purpose Week 3 Quiz Answer

Computer Science Programming with a Purpose Week 3 Quiz Answer

Computer Science: Programming with a Purpose Week 3 Quiz Answer


In this article i am gone to share Coursera Course Computer Science: Programming with a Purpose Week 3 | Arrays Quiz Answer with you..


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]):

  • 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]) ;


  • 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

0 Comments