Cookie Consent by Free Privacy Policy Generator Computer Science: Programming with a Purpose Week 9 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 9 Quiz Answers - Coursera!

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

Creating Data Types

Question 1) Of the following, which best describes a class in Java?

Defines data type values
Implements a data type
Implements a test client
Creates and initializes new objects
Implements operations on data type values

Question 2) What does a constructor return?

An object
Nothing (no return value)
A reference to an object
Instance variable values
A method that creates an object

Question 3) What does an instance variable refer to in an instance method?

A value in the scope of the method
A value in the scope of the method's client
A value in the scope of the constructor associated with the method
A value associated with the object that was used to invoke the method
An object that was created by the constructor associated with the method

Question 4) A shadow in a Java data type implementation refers to which of the following?

Two constructors with the same name
An instance method with the same name as a constructor
A local variable with the same name as an instance variable
An instance variable with the same name as a constructor
An instance method with the same name as a static method

Question 5) Suppose you want to add a constructor to Complex that takes a double value as its argument and creates a Complex number with that value as the real part (and imaginary part equal to 0). You write the following code:

public void Complex(double real) 
{
   re = real;
   im = 0.0; 
}

But then the statement Complex C = new Complex(1.0) does not compile. Why?

The types of re and im are not declared.
A class can only have one constructor.
Constructors do not have return types, not even void.
The return type should be complex, not void.
None of the above.

Post a Comment

Previous Post Next Post