AP Programming Chapter 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Instance variables that are numbers are initialized to what default value?

0

What is a tester class?

A class with a main method that contains statements to run methods of another class.

What is the return type of a constructor?

A constructor does not have a return type.

What is a local variable?

A variable that is declared in the body of a method.

What is a parameter variable?

A variable that is declared in the header of a method.

What is the name of the constructor for the BankAccount class?

BankAccount

When are instance variables initialized?

Instance variables are initialized with a default value before a constructor is invoked.

If a method has two parameters, one explicit and one implicit, and a return type of void, then the documentation comments should include:

One @param statement, and no @return statement

Which of the following statements is true about constructors?

Providing a constructor for a class is optional.

Which statement is true about the following constructor of the BankAccount class? public BankAccount(double balance) { this.balance = balance; }

The code sets the instance variable balance to the parameter variable balance.

When are local variables initialized?

You must initialize local variables in a method body.

What do static variables belong to?

a class

What do parameters and local variables belong to?

a method

Identify the explicit parameter of the withdraw method of the BankAccount class.

amount

What is the name of the parameter variable of the recordPurchase method of the CashRegister class?

amount

A method header consists of which of the following parts?

an access specifier, a return type, a method name, and a list of the parameters (if any)

A class declaration consists of which of the following parts?

an access specifier, the keyword class, the name of the class, declarations for instance variables, constructors, and methods

An instance variable declaration consists of which of the following parts?

an access specifier, the type of the instance variable, and the name of the instance variable.

What do instance variables belong to?

an object

What is the name of the instance variable for a BankAccount object?

balance

When you declare a method, you also need to provide the method ____, which consists of statements that are executed when the method is called.

body

Private instance variables ___.

can only be accessed by methods of the same class

What is the name of the local variable of the giveChange method of the CashRegister class?

change

Information hiding makes it simpler for the implementor of a class to _____.

change the private implementation

The name of the constructor is always the same as the name of the __.

class

Documentation ___ can be used to describe the classes and public methods of programs.

comments

What contains the instructions to initialize the instance variables of an object?

constructor

When drawing complex shapes, provide a(n) ____ to set the position of the shape.

constructor

What is the process of hiding object data and providing methods for data access called?

encapsulation

You should provide documentation comments for ___.

every class, every method, every parameter, and every return value

In the statement below, amount is referred to as the ____ parameter. public void deposit(double amount)

explicit

Encapsulation allows a programmer to use a class without having to know its ____.

implementation

A method is invoked on what type of parameter?

implicit parameter

Each object of a class has its own set of ___.

instance variables

What does an object store its data in?

instance variables

The private implementation of a class consists of ___.

instance variables and the implementation of the constructors and methods

The public constructors and methods of a class form the public _____ of the class.

interface

What is the name of the utility that formats comments into a set of documents that you can view in a Web browser?

javadoc

When a method exits, its ____ are removed.

local variables

Consider the following invocation of the deposit method: mySavings.deposit(250); What is the implicit parameter?

mySavings

Instance variables that are object references are initialized to what default value?

null

The black boxes from which a program is manufactured are called ___.

objects

You should declare all instance variables as ___.

private

We want to change the BankAccount class so that all accounts will have a monthly fee. When a BankAccount is created, its monthly fee is set and cannot be changed. Which of the following will properly define the instance variable monthlyFee that holds the monthly fee?

private double monthlyFee;

Which of the following declares a sideLength instance variable for a Square class that stores an integer value?

private int sideLength;

We want to change the BankAccount class so that all accounts will have a monthly fee. When a BankAccount is created, its monthly fee is set and cannot be changed. The instance variable monthlyFee will hold the monthly fee. Which of the following is the correct public interface for a constructor that sets both the initial balance and monthly fee? __________________________ { double monthlyFee; // The rest of the constructor code follows }

public BankAccount (double initialBalance, double monthlyFee)

Which of the following corresponds to a valid constructor header for the Player class?

public Player()

Which of the following is a valid constructor header for the Player class that accepts the player name as a parameter?

public Player(String playerName)

Which of the following corresponds to the getArea method header for a Square class assuming an integer value for a side length?

public int getArea()

What are the operations that any programmer can use to create and manipulate objects of the class called?

public interface

Which of the following is an instance variable of the CashRegister class?

purchase

What statement is used to specify the value that a method gives back to its caller?

return

Which of the following corresponds to the getArea method body for a Square class where the instance variable is named sideLength?

return sideLength * sideLength;

Which of the following corresponds to the constructor body for a Square class that accepts an initial side length value where the instance variable is named sideLength?

sideLength = initialLength;

The use of an instance variable name inside a method denotes the instance variable of what?

the implicit parameter

Which of the following denotes the implicit parameter?

this

Consider the constructor of the BankAccount class that has a parameter for the initial balance. Which line of code is equivalent to this constructor body? balance = initialBalance;

this.balance = initialBalance;

What verifies that a class works correctly in isolation, outside a complete program?

unit test

What is the return type of the println method of the PrintStream class?

void


Set pelajaran terkait

Prep U Chapter 34: Assessment and Management of Patients with Inflammatory Rheumatic Disorders

View Set

World Geography - Unit 4 - Europe

View Set

2C- 4- The Financial Services Modernization Act of 1999 (Gramm-Leach-Bliley Act / GLBA)

View Set

Life insurance policy provisions, options, and riders

View Set

Marketing Unit 3 Final questions

View Set

CHEM 123 SAPLING LEARNING CHAPTER 12

View Set

Exam FX Completing the Application, Underwriting, and Delivering the Policy

View Set

Adult, Child, and Infant Choking

View Set