Friday, May 6, 2011

chapter 6

Instance methods do not have the key word static in their headers.
==true

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";
==Both 1 and 2

It is common practice in object-oriented programming to make all of a class's
==fields private

Another term for an object of a class is a(n)
== instance

One or more objects may be created from a(n)________.
==class

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

Which of the following statements will create a reference, str, to the String, "Hello, World"?
==String str = “Hello, World”;

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 int getOrderAmount()
{
return orderAmount;
}
public int getOrderDisc()
{
return orderDisc;
}
}

public class CustomerOrder
{
public static void main(String[] args)
{
int ordNum = 1234;
double ordAmount = 580.00;
double discountPer = .1;
Order order;
double finalAmount = order.getOrderAmount() —
order.getOrderAmount() * order.getOrderDisc();
System.out.println("Final order amount = $" +
finalAmount);
}
}
====There is no value because the object order has not been created

The following package is automatically imported into all Java programs.
==java.lang

The scope of a private instance field is
==the instance methods of the same class


Look at the following statement.

import java.util.*;

This is an example of
==A wildcard import

In a UML diagram to indicate the data type of a variable enter
==The variable name followed by a colon and the data type

When an object is created, the fields associated with the object are called
==instance fields

In your textbook the general layout of a UML diagram is a box that is divided into three sections. The top section has the _________; the middle section holds _________; the bottom section holds _________.
==Class name; fields; methods

A constructor is a method that is automatically called when an object is created.
==true

 
It is common practice in object-oriented programming to make all of a class's
==fields private

The following package is automatically imported into all Java programs
==java.lang

After the header, the body of the method appears inside a set of
==Braces, {}

A UML diagram does not contain ________.
==object names


What does the following UML diagram entry mean?

+ setHeight(h : double) : void
~~This is a public method with a parameter of data type double and does not return a value


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

A class’s responsibilities include
~Both A and B

For the following code, which statement is not true?

public class Circle
{
private double radius;
public double x;
private double y;
}

~~~y is available to code that is written outside the Circle class



No comments:

Post a Comment