U3: User Defined Methods Flashcards
1
Q
Trial and Error
A
Create program, run it, alter code until desired result
2
Q
Stepwise Refinement
A
- Completing program in trial-and-error method closer and closer to solution
- Ex: Writing first part of program, perfecting, then continuing
3
Q
Divide and Conquer
A
Breaks task into smaller parts
4
Q
Modular Programming
A
- Building large programs through combining separate chunks of code
- Possible by creating main program, then creating separate subroutines for program
5
Q
Method Header
A
- public static void [method] (data)
- AKA: Subroutine definition
6
Q
Method Body
A
Code of the method
7
Q
Modifiers
A
Ex: public and static
8
Q
public/private
A
- Access specifier stating where subroutine can be called from
- Private: Just within selected part of program
- Public: Other parts
9
Q
Naming Conventions for Subroutine
A
- Begin with lowercase
- Camel notation
- Descriptive name
- No reserved words
10
Q
Static
A
Ensures subroutine can exist on own and not as part of object
11
Q
Local Variables Inside Subroutine
A
- Different, simpler name from ones in main program
- Only exist within subroutine
- Wiped from memory when subroutine done executing
12
Q
Program Control for Subroutine
A
- Program control transferred to subroutine when latter is called
- Transferred to main program when subroutine done executing
13
Q
Procedure
A
Performs task but doesn’t return data to main program; returns void
14
Q
Data Transfer from Main Program to Subroutine
A
Write arguments in brackets in same order as parameters
15
Q
Function
A
- Performs task and returns data to main program
- Return type specified and return statement concludes subroutine