CPSC Week 09 Test

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

In program Java0710.java, why are all of the method calls preceded with "House."?

These methods are all in the House class.

If you are calling a class method, when is using the class identifier optional?

Use of the class identifier is optional if a *method is called from* a program statement in another method, which resides in the *same class as the method being called*

If you are calling a class method, when is using the class identifier required?

Use of the class identifier is required if a *method is called in a program statement that resides outside the class of the method* that is being called.

What are local variables?

Variables declared inside a method or block

Can the actual parameter identifiers be the different from as the formal parameter identifiers?

Yes

Can the actual parameter identifiers be the same as the formal parameter identifiers?

Yes

Class variables are also called _______.

attributes or static variables

Common methods should be placed in a ____________________.

class

Similar methods accessing the same data should be placed in a __________________.

class

Control structures and block structure need to use a __________________ indentation style.

consistent

In the statement int num; int is the _________________ and num is the _________________.

int is the *data type* and num is the *variable*

List 4 simple data types.

int, double, char, and boolean

Objects contain data and what else?

methods

Specific tasks should be placed in modules called _______________.

methods

What do simple data types store?

only a single value

The key difference between creating no-parameter methods and parameter methods is the ______________.

parameter declaration

All method declarations have an identifier followed by _____________________.

parentheses

List 2 methods that do NOT require any parameters?

println() and nextInt()

It is not possible to create large, reliable programs without being very conscious of ________________.

program design

What word do you NOT use when declaring a 2nd or 3rd class in a program?

public

Programs should use __________________ identifiers.

self-commenting

List the 3 trigonometric methods of the Math class.

sin, cos and tan

What are the methods called that are incomplete, but do have a heading and a set of braces?

stubs

What method is contained in the driving class?

the main method

The corresponding actual parameters in the method call must be the same ________ as the formal parameters in the heading.

type

What are the 2 categories of methods (both class and object)?

void and return methods

What kind of values do void methods return?

void methods do not return any values.

An actual parameter can be several different things. List 5 examples.

*1* Constant only *2* Variable only *3* Expression with constants only *4* Expression with a variable and a constant *5* method call that returns the appropriate value

List 3 ways a return method can be called.

*1* in a println stament, *2* in an assignment statement *3* in a conditional statement

What is the difference between an actual parameter and a formal parameter?

Actual parameters are in the method call. Formal parameters are in the method heading.

Which methods have access to a class variable?

All of the methods of that class

Refer to the previous question. Why was this not necessary in program Java0709.java?

All of the methods were in the same class.

In the statement Bank tom; Bank is the _________________ and tom is the _____________.

Bank: *data type*; tom: *variable*

If you are in the main method, and you want to call a *hiss method* from a *Boo class*, what would be the exact syntax?

Boo.hiss();

Class methods are normally what?

Class methods are normally utility methods that do not access changing data fields. (like MATH class)

What is the next step in writing your graphics program?

Complete one method at a time and test that method before continuing to the next method.

Output to the monitor requires the use of a ____________ object.

Graphics

In the paint method of program Java0715.java three different classes appear. Why are methods called from three different classes to draw a house?

In this program there is also a background displayed with the Background class and a tree is displayed with the Tree class.

Where are class variables declared?

Inside a class, but outside of any method

Why are such methods (stubs) created incomplete?

It allows the program to compile before every method is completed.

If a variable is used by two or more methods of a class, how should it be declared?

It should be declared as a class variable.

If a variable is only used by one method, how and where should it be declared?

It should be declared inside that method as a local variable.

How must the methods of the Math class be accessed?

Methods in Math are class methods and must be accessed using the Math class identifier. (Math.PI)

Why does program *Java0705.java* not compile?

Methods of the Address class are called from the main method, but without the Address class identifier.

What 2 things do class data types store?

Multiple pieces of information (*class attributes*) as well as several methods (*class acions*)

If a method has several parameters, do they all need to be of the same type?

No

Where can local variables be accessed?

Only inside the method or block that they are defined in

If you select to divide the graphics output into multiple modules you need to make sure that you do what?

Pass the Graphics object to the other modules. public static void drawChimney(*Graphics g*){}

What is a good start for a graphics program?

Start with the paint method and enter the method calls for the different parts of the program.

The _____________________ of the ____________________ in the ____________________ must match the sequence of the formal parameters in the heading.

The *sequence of the actual parameters in the method call* must match the sequence of the formal parameters in the heading.

What is the essence of program design?

The essence of program design is the creation of practical classes and the proper interaction of these classes.

What should the main method be used for?

The main method should be used for program sequence, not large numbers of program statements.

The number of parameters in the method call must match what?

The number of parameters in the method heading

What Applet method controls the graphics display of an Applet in the same manner that the main method controls the sequence in an application program?

The paint method

What is the driving class responsible for?

The program execution sequence


Kaugnay na mga set ng pag-aaral

ML 350- Final Exam (Multiple Choice)

View Set

The Peripheral Nervous System: Efferent Division

View Set

Chapter 1: Concepts and Trends in Healthcare

View Set

Business Management - Ch 14 - Exam 3

View Set

World History Finals Study Guide

View Set

14-Regulation of Bacterial Gene Transcription

View Set