cpcs

Ace your homework & exams now with Quizwiz!

In a well-designed program, what should the main or paint method resemble?

An outline

Some of the first programming tools created were translating programs like ____ and _____

compilers and interpreters

List 4 important rules for using methods with parameters

1.The number of parameters in the method call must match the number of parameters in the method heading.2.The corresponding parameters in the method call must be the same type as the parameters in the method heading. 3. The sequence of the parameters in the method call must match the sequence of the parameters in the method heading. 4.The identifiers of the parameters in the method call may be the same as or different from the identifiers of the parameters in the method calling

How many lines of code are in a modern video game?

500,000 line of program code

What is a subroutine?

A group of program commands combined into a single module for a specific purpose

List 3 things required by a user-defined method

A heading (including method name). a set pf braces to contain the method body statements, a body of program statements inside the braces

What is a stub?

A method with a proper heading, but nothing in between the braces

Consider programs SimpleMethods01.java and GrfxMethods01.java. Why does the book say that both programs have "poor program design"?

Because all the program statements are all inside the <paint> method

Look at the paint method in program GrfxMethods03.java. Why are all of the method calls preceded with the class identifier House?

Because it's better program design and now they're in their own class

Compare programs SimpleMethods03.java and SimpleMethods04.java.

Both programs have identical main methods which call 3 other methods using only the method identifiers.

Compare programs SimpleMethods02.java and SimpleMethods03.java.

Both programs have the same fullName, Street, and cityStateZip methods.

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

Constants, variables, expressions with constants only, expressions with variables and constants, and return method calls

What is the second step in creating a big graphics program?

Create stubs

What is the first step in creating a big graphics program?

Create the paint method

Compare programs SimpleMethods04.java and SimpleMethods05.java. How does the second program cure the problem of the first?

Cures it because it uses the class-dot-method format to call any of the <address> methods

What are subroutines called in C++?

Functions

Any method that needs to display graphics output requires which parameter?

Graphics object g

Where is the data type of the returning value declared?

In the heading

Explain the class-dot-method format for calling methods.

It calls the "toolbox" and then the special "tool" you want to use from that method

Look at program MethodsFromMethods03.java. Give 2 examples of how this program confirms your answer to the previous question.

It calls the class of a random star and then it uses it in night sky as well as the moon beings its own class and being put in the nightsky

The first program works. Why does the second program not compile?

It doesn't compile because the <fullname>, <street> and <cityStatezip? Methods are no longer contained in the <SimpleMethods04> class

Look at program GrfxMethods06.java and its output. How does this program fix the problem of program GrfxMethods05.java?

It fixes It by drawing the background first

A return method does not have the keyword void in its heading. What does it have instead?

It has a data type

Look again at program VoidMethods05.java. What is wrong with Line 2?

It has formal parameters but they require their own data type

When you are finished with step 1, your program will not compile. Why is this?

It is attempting to call methods that don't exist

Look at program SimpleMethods06.java. This program calls methods of the Address class, but the Address class is nowhere to be found in the file. Where is the Address class?

It is in the file Address.java

When the Java compiler encountered the statement Address.fullName();how does it know in which file to look to find the Address class?

It knows because it has been declared public

The first program called the methods using the class-dot-method format. The second program calls the methods just by using the method name. How does this work if the name of the class is not specified?

It works because all the methods are in the same class

Are parameters necessary for all methods, or just the majority of them?

Just the majority of the methods

Look at program ReturnMethods01.java. What is return by the getNextNumber method?

N++, returns an n + 1

What is the class identifier?

Name of the class

What is the method identifier?

Name of the method

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

No

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

No

Refer to the previous question. You need to call this new method from the paint method. Write the method call below. Make sure this method call is consistent with the other 4 method calls in the paint method.

Picket (g,x)

What are subroutines called in Pascal?

Procedures and functions

Assume you are creating a graphics program with multiple methods, similar to Java0808.java. What needs to be in the heading of each of these methods?

Public static void

What 3 Java keywords have been at the beginning of every single method that you have seen thus far?

Public static void

Refer to the previous question. What parameter needs to be passed in each method call?

Public static void User-defined parameters

What does it mean when a method is overloaded?

This means they can be used in different situations with different types of parameters or a different number of parameters

What is the fifth step in creating a big graphics program?

Repeat step 4 until the entire program is done

What are subroutines called in FORTRAN?

Subroutines

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

The calling parameter is officially called the actual parameter and the receiving parameter is called the formal parameter

Look at program ReturnMethods03.java. There are 2 add methods, one called add1 and the other add2.Which of these is a void method and which is a return method?

The first one is the void, and the second is the return method

If a program has more than one class, which class is the primary class?

The one with the same name as the file

If a program has more than one class, which class is declared public?

The primary class

When you are finished with step 2, your program will compile and execute, but it will have no output. Why is this?

The stubs don't have anything in them

Explain how calling a return method is different from calling a void method.

The void methods calls stand by itself while the return method is called in a program statement that uses the return value

What is the difference between calling methods that you have created yourself and calling other methods?

There is no difference

Look at program VoidMethods05.java. What is wrong with Line 1?

They have data types inside the parenthesis

Look at the paint method in program GrfxMethods04.java. Why are some of the method calls preceded with the class identifier House and others preceded with the class identifier Tree?

They're different classes and need to use different methods

What is the purpose of a return method?

To return a value to the calling method statement

Look at program ReturnMethods02.java. What is accomplished by the checkPIN method?

Uses a Boolean vale true or false depending on the correct entry of the pin

When is using the class identifier required?

When you are calling a method that is in a different class

When is using the class identifier optional?

When you are calling a method that is in the same class

Assume the existence of a Greetings class which contains a method called hello.

Write necessary Java code to call the hello method. Greeting.hello();

What is the third step in creating a big graphics program?

Write the first method and make sure it works

What is the fourth step in creating a big graphics program?

Write the next method and make sure it works

Can a program have other "secondary" methods besides the main or paint methods?

Yes

Can one method be used to create another method?

Yes

Can return methods have multiple parameters?

Yes

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

Yes

Does parameter sequence matter?

Yes, it is very important

Information is passed from the __________ to the _________.

actual parameter, formal parameter

What are subroutines called in Java

methods

The key difference between creating parameter methods and non-parameter methods is the

parameter declaration

All method declarations have an identifier followed by

parentheses.

The last program statement in a return method must always be a _______ statement.

return

It is in the nature of people to create things that make our lives simpler and more enjoyable. To that end, it is also in the nature of people to create ______ to make this process easier and more efficient.

tools

If a method does not return a value, the return data type is not applicable and becomes

void

Methods with the word void in the method heading are called _____ methods

void


Related study sets

Chapter 1 (all chapters and quiz q's)

View Set

Exam 1 A&P Abdominopelvic Quads/ Regions

View Set

Patho Chapter 17 Cardiac Function and Assessment

View Set

Male and female reproductive system

View Set

Developmental Stages: Infancy to Adolescents

View Set

Vocabulary Power Plus for the ACT Book 3-Lesson 13 (+synonyms and antonyms)

View Set

Micro test 2 ch. 18 MCAT practice test

View Set