l

Ace your homework & exams now with Quizwiz!

Functional decomposition is

The process of breaking a problem down into smaller pieces

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

Fields private

A constructor

Has the same name as the class

Overloading means multiple methods in the same class

Have the same name, but different parameter lists

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

In order to avoid having stale data

This type of method method performs a task and sends a value back to the code that called it.

Value-returning

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

import

Assume that the following method header is for a method in class A.public void displayValue(int value)Assume that the following code segments appear in another method, also in class A. Which contains a legal call to the displayValue method?

int x = 7;displayValue(x);

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

+

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

-

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.println("Final order amount = $" +finalAmount);} }

522.00

When writing the documentation comments for a method, you can provide a description of each parameter by using a

@param tag

In the following code, Integer.parseInt(str), is an example of ________.int num;string str = "555";num = Integer.parseInt(str) + 5;

A value-returning method

In the following code, System.out.println(num), is an example of ________.double num = 5.4;System.out.println(num);num = 0.0;

A void method

When an object, such as a String, is passed as an argument, it is

Actually a reference to the object that is passed

Breaking a program down into small manageable methods

All of the above

Local variables

All of the above

Look at the following statement.import java.util.Scanner;This is an example of

An explicit import

A value-returning method must specify this as its return type in the method header.

Any valid data type

All @param tags in a method's documentation comment must

Appear after the general description of the method

Values stored in local variables

Are lost between calls to the method in which they are declared

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

Methods are commonly used to

Break a problem down into small manageable pieces

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

Class

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

In the cookie cutter metaphor: Think of the ________ as a cookie cutter and ________ as the cookies.

Class; objects

If method A calls Method B, and method B calls method C, and method C calls method D, when method D finishes, what happens?

Control is returned to method C

When an argument value is passed to a method, the receiving parameter variable is

Declared in the method header inside the parentheses

In a @return tag statement the description

Describes the return value

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

Encapsulation

When an argument is passed to a method,

Its value is copied into the method's parameter variable

You should always document a method by writing comments that appear

Just before the method's definition

A UML diagram does not contain ________.

Object names

This is a group of related classes.

Package

A constructor is a method that

Performs initialization or setup operations

Which of the following is not part of a method call?

Return type

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

String str = "Hello, World";

To document the return value of a method, use this in a documentation comment.

The @return tag

What is wrong with the following method call? displayValue (double x);

The data type of the argument x should not be included in the method call

The header of a value-returning method must specify this.

The data type of the return value

The scope of a public instance field is

The instance methods and methods outside the class

The scope of a private instance field is

The instance methods of the same class

What will be the result of the following code?int num;string str = "555";num = Integer.parseInt(string str) + 5;

The last line of code will cause an error

In a UML diagram to indicate the data type of a variable enter

The variable name followed by a colon and the data type

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

They have different parameter lists

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

What will be returned from the following method?public static int methodA(){double a = 8.5 + 9.5;return a;}

This is an error

Look at the following statement.import java.util.*;This is an example of

a wildcard import

Given the following method header, which of the method calls would cause an error? public void displayValues(int x, int y)

displayValue(a,b); // where a is a short and b is a long

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


Related study sets

Financial Accounting Module 6 - Analyzing Financial Statements

View Set

Chapter 1: ENV Problems, Their Causes, and Sustainability

View Set

BISC 104 Mastering Biology Chapter 7

View Set

ECONOMICS-UNIT 1 QUIZ 3 & practice test

View Set

Geog 100 Chapter 9: Endogenic Processes

View Set