CS 202 - Quiz 06

¡Supera tus tareas y exámenes ahora con Quizwiz!

In UML diagrams, this symbol indicates that a member is public.

+

Which of the following statements will create a reference, str, to the string, "Hello, world"? (1) String str = new String("Hello, world"); (2) String str = "Hello, world";

1 and 2

Given the following code, what will be the value of finalAmount when it is displayed? public class Order { private int orderNum; private double orderAmount; private double orderDiscount; public Order(int orderNumber, double orderAmt, double orderDisc) { orderNum = orderNumber; orderAmount = orderAmt; orderDiscount = orderDisc; } public double finalOrderTotal() { return orderAmount - orderAmount * orderDiscount; } } public class CustomerOrder { public static void main(String[] args) { Order order; int orderNumber = 1234; double orderAmt = 580.00; double orderDisc = .1; order = new Order(orderNumber, orderAmt, orderDisc); double finalAmount = order.finalOrderTotal(); System.out.printf("Final order amount = $%,.2f\n", finalAmount); } }

522.00

A class's responsibilities include:

Both A & B

This refers to the combining of data and code into a single object.

Encapsulation

A method that gets a value from a class's field but does not change it is known as a mutator method.

False

When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable

False

Java allows you to create objects of this class in the same way you would create primitive variables.

String

A class in not an object, but a description of an object.

True

In the cookie cutter metaphor, think of the ________ as a cookie cutter and ________ as the cookies.

class; objects

Instance methods should be declared static.

false

A class specifies the ________ and ________ that a particular type of object has.

fields; methods

Overloading means multiple methods in the same class:

have the same name, but different parameter lists

Quite often you have to use this statement to make a group of classes available to a program.

import

You should not define a class field that is dependent upon the values of other class fields:

in order to avoid having stale data

Another term for an object of a class is:

instance

When an object is created, the attributes associated with the object are called:

instance fields

Methods that operate on an object's fields are called:

instance methods

Two or more methods in a class may have the same name as long as:

they have different parameter lists

Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable.

true


Conjuntos de estudio relacionados

The classical civilization (Mediterranean)

View Set

Chapter 63 Musculoskeletal Problems

View Set

Huckleberry Finn Study Guide (Pre-Ap English 9)

View Set

NWM Exam types of life insurance polices

View Set

Chapter 15- Assessing the Head and Neck

View Set