Ahmed Elmalla - AP Computer Science A Java Methods: Parameters, Return Values and FRQ Practice | Class 24 - Your Dedicated Computer Science Tutor | Learn with Kemo
Ahmed Elmalla | AP Computer Science A (Java) Tutor
AP Computer Science A (Java) Tutor Java Programming Tutor (Beginner to Advanced) IGCSE & A-Level Computer Science Tutor Python Programming Tutor for Beginners First lesson available at a discounted rate
Ahmed Elmalla | AP Computer Science A (Java) Tutor

Blog

AP Computer Science A Java Methods: Parameters, Return Values and FRQ Practice | Class 24

AP Computer Science A Java Methods: Parameters, Return Values and FRQ Practice | Class 24

  • H1: AP Computer Science A Java Methods: Parameters, Return Values and FRQ Practice
    • H2: Why Java Methods Can Feel Difficult on AP CSA FRQs
    • H2: Turn the English FRQ Prompt Into Java Code
      • H3: Find the Method Name, Parameters and Return Type
    • H2: Parameters vs Arguments in Java
    • H2: What a Return Value Actually Does
      • H3: Returning Is Not the Same as Printing
    • H2: Calling a Method From Another Method
    • H2: Building the Gross Pay and Net Pay Example
      • H3: Reusing grossPay Instead of Recalculating It
    • H2: Working With Tax Percentages and double Values
    • H2: Why Integer Division Can Break a Calculation
    • H2: Tracing Java Method Calls Step by Step
      • H3: Following Values From main and Back Again
    • H2: Fahrenheit-to-Celsius Method Practice
    • H2: Building a Second Method From an Existing Method
    • H2: Common AP CSA Method-Writing Mistakes
    • H2: A Reliable Strategy for Handwritten Java FRQs
    • H2: Conclusion
    • H2: AP CSA Java Methods FAQs

AP Computer Science A Java Methods: Parameters, Return Values and FRQ Practice

  • If you've ever looked at an AP Computer Science A Java FRQ, understood the code in front of you, and then suddenly felt stuck when asked to write a method yourself, you're dealing with a very common programming-learning problem. Reading code and producing code are related skills, but they aren't identical. When you're reading, Java has already made most of the decisions for you: the method name exists, the parameters are there, the variables have names, and the return statement has already been written. When you're staring at a blank page, you have to make all those decisions yourself. That's why a student can be fairly comfortable with AP CSA multiple-choice questions and still find method-writing questions surprisingly difficult.

    This tutoring session focuses directly on that gap. Rather than treating Java methods as isolated pieces of syntax, the lesson follows values as they move between methods. We work with a netPay calculation that relies on an existing grossPay method, then move into temperature-conversion problems where one method must reuse another method. The student doesn't simply type an answer and move on. Instead, the execution is traced so we can see what happens when arguments are passed into parameters, when one method calls another, and when a calculated value is returned to the original caller.

    Once that flow clicks, Java methods stop looking like disconnected boxes. They start looking more like people passing information along a chain: one method receives information, performs its responsibility, hands a result back, and another method continues the job.

    Why Java Methods Can Feel Difficult on AP CSA FRQs

    One particularly revealing moment in the tutoring material is the student's explanation of the problem: reading code isn't necessarily the main difficulty. The student can often follow code or work through questions asking what a program will output, but handwriting a solution independently becomes confusing. That's an important distinction because AP CSA preparation shouldn't only consist of reading finished solutions. If you always study by looking at completed code, you're training recognition when the skill you eventually need may be production.

    Method-writing problems also pack several decisions into a tiny amount of text. Consider a prompt that asks you to write a method, gives it a particular name, says it receives two double parameters, and says it returns a double. Before you've written a single calculation, the question has already told you most of the method header. Yet when students rush toward the mathematical part, those structural clues are easy to miss. A forgotten variable name, wrong return type, missing parameter, or incorrect method call can derail code even when the underlying mathematical idea is correct.

    The session addresses exactly this kind of mistake. The student discusses forgetting variable names while handwriting code, and the tutoring response emphasizes that a variable declaration needs both its data type and its identifier. That's a small syntax rule with a much bigger lesson behind it: don't hold the entire solution in your head at once.

    Instead, extract the requirements first. Build the skeleton. Then fill in the calculation.

    Turn the English FRQ Prompt Into Java Code

    One of the most useful habits for AP CSA is learning to treat the wording of a programming question as a specification rather than a paragraph you need to memorize. The prompt is giving you clues. Your job is to translate those clues into Java components.

    Suppose a problem effectively tells you that a method named fahrenheitToCelsius takes one double parameter called tempF and returns the corresponding Celsius temperature as a double. Before worrying about the conversion formula, you already have enough information to build something conceptually like this:

    public static double fahrenheitToCelsius(double tempF)
    {
        // calculation
        return ...;
    }
    

    Notice what happened. We haven't solved the mathematics yet, but the blank page is no longer blank.

    That is enormously useful under exam pressure.

    The transcript demonstrates this process with the temperature-conversion exercise. The student identifies public, static, the double return type, the method name and the double tempF parameter, while the lesson corrects details such as ending a method header with a semicolon instead of opening the method body with curly braces.

    Find the Method Name, Parameters and Return Type

    Before writing the body of a method, identify four things: method name, parameter list, return type and special requirements.

    If the question says the method “returns … as a double,” that phrase isn't decoration. It's telling you the return type.

    If it says the method “takes two double parameters,” your header needs two parameters of type double.

    If it says those parameters appear in a particular order, respect that order.

    If it says your method must call another method, underline that requirement mentally—or literally, if you're working on paper. Rewriting the calculation yourself may produce the same numerical answer but still fail to follow the specified design.

    The lesson repeatedly practices this translation process because it gives students a repeatable starting point instead of relying on inspiration.

    Parameters vs Arguments in Java

    Parameters and arguments are closely related, which is exactly why they're easy to blur together.

    Imagine this method:

    public static double netPay(double hourlyRate,
                                double hoursWorked,
                                int taxPercent)
    {
        // ...
    }
    

    hourlyRate, hoursWorked, and taxPercent are parameters. They are variables belonging to the method definition.

    Now imagine calling it:

    double pay = netPay(6.0, 11.0, 5);
    

    The values 6.0, 11.0, and 5 are the arguments supplied during that particular call.

    During the lesson, this relationship is traced explicitly: a call using 6, 11, and 5 leads to the corresponding parameter variables inside netPay holding those values.

    This also explains why you shouldn't randomly hard-code another number when netPay needs to call grossPay. The values you need may already exist in the parameters.

    If grossPay expects hourly rate and hours worked, you can pass the current method's variables:

    double gross = grossPay(hourlyRate, hoursWorked);
    

    You're essentially saying: “Take the values currently stored in these parameters and give them to grossPay.”

    That idea—passing existing variables into another method—is central to the whole lesson.

    What a Return Value Actually Does

    Students sometimes describe return as if it automatically prints the answer. It doesn't.

    A return statement sends a value back to the code that called the method.

    Suppose:

    public static double grossPay(double hourlyRate, double hoursWorked)
    {
        return hourlyRate * hoursWorked;
    }
    

    and somewhere else we write:

    double gross = grossPay(6.0, 11.0);
    

    The calculation produces 66.0. That returned 66.0 becomes the value assigned to gross.

    Nothing about return inherently means “display this on the screen.”

    Returning Is Not the Same as Printing

    The tutoring session spends time tracing this exact distinction. When the called method calculates its result, the value is returned to the calling location and can be stored in another variable. The student eventually describes the returned gross-pay result being placed into the gross variable before the surrounding method continues its work.

    Think of a method call as asking a question:

    grossPay(6.0, 11.0)
    

    asks, in effect:

    “What is the gross pay for these values?”

    The method works it out and hands back 66.0.

    Then this statement:

    double gross = grossPay(6.0, 11.0);
    

    says:

    “Whatever answer comes back, store it in gross.”

    That mental model becomes incredibly useful when methods start calling other methods.

    Calling a Method From Another Method

    A major theme of this session is method composition: using a smaller method as part of a larger method.

    Suppose grossPay already knows how to calculate gross income. Now you're asked to write netPay.

    You could copy the multiplication into netPay, but what if the prompt explicitly says you must use grossPay?

    Then method reuse is part of the problem.

    Conceptually:

    public static double netPay(double hourlyRate,
                                double hoursWorked,
                                int taxPercent)
    {
        double gross = grossPay(hourlyRate, hoursWorked);
    
        // use gross to calculate net pay
    }
    

    This is one of those programming ideas that can look mysterious until you trace it. netPay receives values. It passes two of those values to grossPay. Execution moves into grossPay. That method calculates and returns a result. Execution returns to netPay, where the result is stored in gross. Then netPay continues.

    The transcript uses print statements during practice to make this invisible execution path visible. That's a useful debugging and learning technique because it turns an abstract call stack into something the student can follow line by line.

    Building the Gross Pay and Net Pay Example

    The payroll example brings several AP CSA skills together.

    netPay receives three pieces of information: an hourly rate, hours worked and a tax percentage. But the gross amount shouldn't be independently reconstructed if the exercise requires use of the existing grossPay method. The session therefore stores the result of the grossPay call in a variable and uses that returned value in subsequent calculations.

    For example:

    double gross = grossPay(hourlyRate, hoursWorked);
    

    Now imagine the arguments were:

    hourlyRate = 6.0
    hoursWorked = 11.0
    taxPercent = 5
    

    The gross pay is:

    6.0 × 11.0 = 66.0
    

    The lesson then works toward deducting the tax to obtain the net pay. In the example traced during the session, the final result becomes 62.7 after a five-percent tax deduction.

    Reusing grossPay Instead of Recalculating It

    This requirement teaches something bigger than payroll.

    If a question says “must call”, pay attention.

    The purpose may be to test whether you understand how methods interact rather than whether you know the underlying formula.

    The same pattern appears again later with temperature conversion. A smaller method solves one problem; a larger method calls it, possibly multiple times, and uses its returned results to solve a new problem.

    Once you recognize that pattern, many method-based FRQs become less intimidating.

    Working With Tax Percentages and double Values

    Percentages create another opportunity for mistakes.

    If taxPercent contains 5, the value represents five percent—not 0.05 yet.

    To calculate the amount of tax, the algorithm needs to convert that percentage appropriately and apply it to the gross pay. The session walks through why the tax should be based on gross pay, not simply the hourly rate: hourly rate is only the amount earned per hour, whereas gross pay represents the total before tax.

    Conceptually, we want something like:

    double tax = gross * (taxPercent / 100.0);
    return gross - tax;
    

    The final subtraction also needs to make conceptual sense. You're subtracting a money amount from another money amount.

    If gross pay is $66.00, you shouldn't subtract the number 5 simply because the tax rate is 5%. You calculate what 5% of $66.00 actually is, then subtract that tax amount.

    Thinking about the units can often reveal a broken expression before the compiler does.

    Why Integer Division Can Break a Calculation

    Java's numeric types matter.

    Suppose taxPercent is an int containing 5.

    If you carelessly write an expression where both operands in a division are integers, Java's integer-division behavior can destroy the fractional portion you were expecting.

    That's why a percentage calculation often deliberately introduces a floating-point value:

    taxPercent / 100.0
    

    instead of relying on:

    taxPercent / 100
    

    The .0 looks tiny, but its effect isn't.

    It helps ensure the division operates in floating-point arithmetic, allowing five percent to become 0.05 rather than losing the fractional result through integer division.

    This is exactly the sort of small Java detail that can turn logically correct reasoning into incorrect code. When working on AP CSA problems involving percentages, averages, ratios, or other fractional calculations, always inspect the operand types—not just the formula.

    Tracing Java Method Calls Step by Step

    When method calls feel confusing, don't stare at the whole program.

    Trace one value.

    Suppose main contains:

    double pay = netPay(6.0, 11.0, 5);
    

    First, execution enters netPay.

    Its parameters receive the supplied values.

    Inside netPay, this might happen:

    double gross = grossPay(hourlyRate, hoursWorked);
    

    Execution now moves into grossPay.

    grossPay receives 6.0 and 11.0, calculates 66.0, and returns it.

    Execution returns to netPay.

    Now:

    gross = 66.0
    

    The tax calculation happens, and netPay returns its final result.

    That result travels back to the original call in main, where it is stored in pay.

    Following Values From main and Back Again

    A useful visualization is:

    main → netPay → grossPay → netPay → main

    The transcript spends significant time following this execution flow because it was one of the concepts requiring reinforcement. The lesson even adds temporary print statements such as messages indicating when execution is “inside net pay” or “inside gross pay,” making it easier to see the order in which methods execute.

    You can use the same technique while studying.

    Don't just ask, “What does this program output?”

    Ask:

    Where am I now? What values do the parameters contain? Which method gets called next? What does it return? Where does that returned value go?

    That's code tracing with purpose.

    Fahrenheit-to-Celsius Method Practice

    The second major exercise shifts away from payroll but deliberately preserves the same method concepts.

    The task begins with a method that takes a Fahrenheit temperature and returns the corresponding Celsius temperature as a double. The student identifies the method structure and discusses two legitimate coding styles: calculating the Celsius result in a local variable before returning it, or placing the calculation directly in the return expression.

    For example, one style might conceptually look like:

    public static double fahrenheitToCelsius(double tempF)
    {
        double celsius = /* conversion */;
        return celsius;
    }
    

    while another might be:

    public static double fahrenheitToCelsius(double tempF)
    {
        return /* conversion */;
    }
    

    The important question isn't which version has fewer lines.

    It's whether you understand what the expression is doing.

    Short code isn't automatically better code when you're still learning. If intermediate variables help you see the steps, use them. Once the pattern becomes natural, you can often compress the solution safely.

    Building a Second Method From an Existing Method

    The next exercise makes the concept more interesting.

    A new method receives two Fahrenheit temperatures and needs to determine how many Celsius degrees apart they are. But there's an explicit requirement: the conversion method must be called for each Fahrenheit value.

    That suggests a structure like:

    double tempF1C = fahrenheitToCelsius(tempF1);
    double tempF2C = fahrenheitToCelsius(tempF2);
    

    Now the larger method has two Celsius values available.

    Only then does it calculate their difference.

    This mirrors the earlier payroll example beautifully:

    Payroll: netPay calls grossPay.

    Temperature problem: tempDifferenceC calls fahrenheitToCelsius.

    Different story. Same programming architecture.

    The transcript also specifies that the requested temperature difference should be positive rather than negative. That means the implementation needs to respect that requirement when calculating the distance between the converted temperatures.

    The broader AP CSA lesson is to watch for constraints hidden inside ordinary English phrases. “Must call,” “positive,” “returns,” “in this order,” and “as a double” all have consequences for your code.

    Common AP CSA Method-Writing Mistakes

    Many mistakes in method questions aren't caused by a lack of programming intelligence. They're caused by losing track of structure.

    A student might know that a variable should hold a calculation but accidentally write the type without a variable name. They might know a method returns a value but confuse returning with printing. They may understand parameters but hard-code numbers when variables should be passed. They might successfully call a method but forget to do something with its returned result. Or they may rewrite a formula even though the prompt explicitly says to call an existing method.

    The session surfaces several of these difficulties naturally, especially the difference between understanding existing code and constructing handwritten code independently.

    The solution isn't to memorize twenty finished methods.

    Build a checklist in your head:

    What is the method called? What does it receive? What does it return? What existing method must it call? What values should I store? What calculation remains? What exactly must I return?

    That's a much more reusable strategy.

    A Reliable Strategy for Handwritten Java FRQs

    When you're handed an AP CSA method-writing question, resist the temptation to immediately write the calculation.

    Read the prompt once.

    Then read it again looking specifically for Java structure.

    Circle or identify the method name.

    Underline the return type.

    Identify every parameter, including its type and order.

    Mark any phrase saying the method must call another method.

    Then write only the method header and braces.

    At that point, ask yourself what information is already available through the parameters. Don't invent hard-coded numbers if the necessary value has already been passed into the method.

    If another method must be called, make that call and decide where its returned value should go.

    Only after you've built that skeleton should you complete the mathematical or logical calculation.

    This approach is especially useful for students who say, “I understand it when I see the answer, but I don't know how to start.”

    Your first task isn't to know the whole answer.

    Your first task is simply to extract the information the prompt has already given you.

    Conclusion

    Java methods become much easier when you stop treating every method as a completely new problem.

    A method has a contract: it receives certain information through parameters, performs a task, and—when it has a non-void return type—returns a value. That returned value can be stored, printed, used in an expression, or passed into another method.

    The payroll and temperature exercises from this tutoring session demonstrate the same underlying pattern repeatedly. One method solves a smaller problem. Another method reuses it. Values travel through parameters, results travel back through return, and the larger program is built by connecting those smaller pieces.

    When practicing for AP CSA, don't only read finished code. Take a blank sheet of paper and reconstruct methods from their English requirements.

    That's where recognition starts turning into programming skill.

    AP CSA Java Methods FAQs

    1. What is the difference between a parameter and an argument in Java?
    A parameter is a variable declared in a method's definition. An argument is the actual value or expression supplied when the method is called.

    2. Does return print a value in Java?
    No. return sends a value back to the calling code. If you want that value displayed, it must eventually be used in an appropriate output statement.

    3. Can one Java method call another method?
    Yes. This session repeatedly practices that idea, including netPay using grossPay and a temperature-difference method using the Fahrenheit-to-Celsius conversion method.

    4. Why should I store a method's returned value in a variable?
    You don't always have to, but storing it can make multi-step code easier to understand and lets you reuse the returned result without repeating the method call.

    5. How can I get better at AP CSA FRQs if I understand code but struggle to write it?
    Practice from a blank page. Extract the method name, parameters, return type and special requirements before writing the method body. Then build the solution one requirement at a time rather than trying to remember an entire finished answer.


 

📘 AP Computer Science A: Java Methods, Parameters, Return Values & FRQ Practice — Lesson Slides

Use these slides to review the key AP Computer Science A (AP CSA) concepts covered in the lesson, including Java method headers, parameters and arguments, return values, method calls, calling one method from another, double and int data types, storing returned values in variables, integer division, percentage calculations, temperature conversion, and tracing method execution.

The slides are especially useful for reviewing the step-by-step Java FRQ problem-solving process and practicing how to turn written method requirements into working Java code.

View / Download the AP CSA Lesson Slides →


Author Bio

Cambridge Computer Science Tutor Author Bio

Ahmed Elmalla is a Computer Science educator, Certified Cambridge International AS & A Level Computer Science (9618) teacher, and software engineer with over 20 years of teaching, software engineering, and international tutoring experience. He specializes in AP Computer Science A (Java) and Cambridge IGCSE (0478) and AS & A Level Computer Science (9618), helping students build strong programming, computational thinking, and exam-solving skills. Through his Learn with Kemo platform, he has mentored students from around the world using practical, exam-focused instruction tailored to each learner's needs. His lessons combine real-world software engineering experience with personalized one-to-one tutoring, making complex Java and Computer Science concepts easier to understand. Ahmed is passionate about helping students gain confidence, improve academic performance, and achieve outstanding results in international Computer Science examinations.

 

LinkedIn: https://www.linkedin.com/in/akelmalla

WhatsApp: https://wa.me/60194028484