ITP 120 Chapter 6

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

Which symbol indicates that a member is public in a UML diagram?

+ (plus)

Which symbol indicates that a member is private a UML diagram?

- (minus)

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 method that gets a value from a class's field but does not change it is known as a mutator method.

FALSE

Instance methods should be declared static.

FALSE

The public access specifier for a field indicates that the field may not be accessed by statements outside the class

FALSE

The term "default constructor" is applied to the first constructor written by the author of the class.

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

You should not define a class that is dependent on the values of other class fields _________

In order to avoid having stale data

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

String

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

String str = "Hello, World";

A class is not an object. It is a description of an object

TRUE

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

TRUE

A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method

TRUE

An access specifier indicates how a class may be accessed.

TRUE

An object can store data.

TRUE

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

TRUE

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

TRUE

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

TRUE

The term "no-arg constructor" is applied to any constructor that does not accept arguments

TRUE

When an object is passed as an argument to a method, the object's address is passed into the method's parameter variable

TRUE

For the following code, which statement is not true? public class Sphere { private double radius; public double x; private double y; private double z; }

The z field is available to code written outside the Sphere class.

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.printf("Final order amount = $%,.2f\n", finalAmount); } }

There is no value because the object, order, has not been created.

What does the following UML diagram entry mean? + setHeight(h : double) : void

a public method with a parameter of data type double that does not return a value

The following statement is an example of __________. import java.util.*;

a wildcard import statement

The following statement is an example of __________. import java.util.Scanner;

an explicit import statement

A class's responsibilities include

both of these -the things a class is responsible for knowing -the things a class is responsible for doing

After the header, the body of the method appears inside a set of _________

braces, { }

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

class

A(n) __________ can be thought of as a blueprint that can be used to create a type of __________

class, object

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

fields private

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

fields, methods

A constructor ________

has the same name as the class

Overloading means that multiple methods in the same class _______

have the same name but different parameter lists

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

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

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

instance methods

The __________ package is automatically imported into all Java programs.

java.lang

A reference variable stores a(n) _______

memory address

Class objects normally have __________ that perform useful operations on their data, but primitive variables do not.

methods

Most of the programming languages used today are ________

object-oriented

A group of related classes is called a(n) ________

package

A constructor is a method that ________

performs initialization or setup operations

When you work with a __________, you are using a storage location that holds a piece of data.

primitive variable

Instance methods do not have the __________ keyword in their headers.

static

Which of the following is not involved in identifying the classes to be used when developing an object-oriented application?

the code

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

A UML diagram does not contain ________

the object names

When an object is passed as an argument to a method, what is passed into the method's parameter variable?

the object's memory address

To indicate the data type of a variable in a UML diagram, you 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

they have different parameter lists

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by __________

using the private access specifier on the class fields

For the following code, which statement is not true? public class Circle { private double radius; public double x; private double y; }

The y field is available to code written outside the Circle class


Conjuntos de estudio relacionados

AD BANKER REVIEW FOR CHAPTER 1: General Insurance

View Set

Chapter 5 - Disorders of the Eye and Ear.

View Set

Urology Pharmacology and Adult Care

View Set

Macroeconomics chapter 12 all terms

View Set

Ch.7 Developmental Psychology 2410

View Set

MIE 201 Exam 2: Chapters 4, 5, 8 Makanui NCSU

View Set

Chapter 3-Introduction to the Fourth Amendment

View Set