2.5.1. ObjUse-WE4-P1¶
Subgoals for Calling a Method
Classify method as static method or instance method
If static, use the class name
If instance, must have or create an instance
Write (instance / class) dot method name and ( )
Determine whether parameter(s) are appropriate
Number of parameters passed must match method declaration
Data types of parameters passed must match method declaration (or be assignable)
Determine what the method will return (if anything: data type, void, print, change state of object) and where it will be stored (nowhere, somewhere)
Evaluate right hand side (RHS) of assignment (if there is one). Value is dependent on method’s purpose
ObjUse-WE4-P1
Scanner input = new Scanner(System.in); System.out.print("Enter Your Full Name: "); String fullName = input.nextLine(); System.out.print("Enter Your Course Name: "); String courseName = input.nextLine();
Q12: What data type is returned by calling nextLine
for an instance of Scanner? (Reading the code for the previous question may provide a hint for this one!)
Put these lines of code in the proper order to read in a decimal then an integer.