Midterm Quizzes

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

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

Overloading means multiple methods in the same class:

Have the same name, but different parameter lists.

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

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; attributes or fields; methods

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

methods

When you are working with a ________, you are using a storage location that holds a piece of data.

primitive variable

Instance methods do not have this key word in their headers:

static

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

+

Consider the following code segment and class. Bank tom = new Bank(500.0); Bank sue = tom; sue.makeDeposit(225.0); tom.makeWithdrawal(100.0); System.out.println(tom.getBalance() + " " + sue.getBalance()); class Bank { private double balance; public Bank(double amount) { balance = amount; } public double getBalance() { return balance; } public void makeDeposit(double amount) { balance += amount; } public void makeWithdrawal(double amount) { balance -= amount; } } What is printed as a result of executing the code segment?

625.0 625.0

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

False

Which of the following are classes from the Java API?

Scanner, Random, PrintWriter

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.

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 the class may be accessed.

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

This is a method that gets a value from a class's field, but does not change it.

accessor


Conjuntos de estudio relacionados

LSAT Sufficient vs. Necessary Assumption Questions

View Set

Practice Exam Oregon Life/Health Insurance

View Set

Prep-u: Chapter 7: Growth and Development of the Adolescent

View Set

DNA and Replication Quiz [(Bio) P.8 - P.9]

View Set

Medical-Surgical Assignment Exam

View Set

MGT 11A - Chapter 1 Practice Quiz

View Set

Series 66 11.29.2016 Incorrect Questions

View Set