MultPractice free response answer 15

MultPractice free response problem from the 2017 AP Computer Science A Exam.

MultPractice is #2 from the from the 2017 AP Computer Science A Free Response problems.

https://secure-media.collegeboard.org/ap/pdf/ap-computer-science-a-frq-2017.pdf

MultPractice class

This is both my time constrained and considered approach.

public class MultPractice implements StudyPractice
{
  private final int first;
  private int second;

  public MultPractice(int f, int s)
  {
    first = f;
    second = s;
  }

  public String getProblem()
  {
    return first + " TIMES " + second;
  }

  public void nextProblem()
  {
    second++;
  }
}

2017 AP CS Exam Free Response Solutions

15 thoughts on “MultPractice free response answer

  1. Z May 4,2017 7:06 pm

    On the exam, for some reason I thought final was written and capitals and wrote “FINAL”. Will I lose points?

    • Brandon Horn May 4,2017 7:29 pm

      I don’t know. The College Board hasn’t released the scoring guidelines yet. The variable doesn’t actually have to be declared as final but having the keyword in all caps could be considered extra code with a side effect.

      Java constants are typically declared in all caps (though the final keyword is still lowercase). I used lowercase here because the field isn’t a constant in the sense that it’s initialized at declaration.

  2. Jimbo May 4,2017 8:30 pm

    I wrote my return statement like ” return first + ” ” + “TIMES” + ” ” + second; ” do you think this is still valid?

  3. Maddie May 4,2017 9:23 pm

    I didn’t put final for the first int. Will that be a point off?

  4. Nick May 4,2017 11:46 pm

    I think I put static for both private variables. So my first variable was “private static final int first,” and my second one was “private static int second.” Will I get a point off, you think?

    • Brandon Horn May 6,2017 10:24 am

      My guess would be that you would lose a point for incorrectly making the variables static. Static variables exist once for the entire class, not once for each instance, so if more than one MultPractice object was created they would share the same variables. This wouldn’t work.

  5. Josh May 5,2017 7:12 am

    Is there a penalty for not using capitalization for the final variable name. like
    private final int FIRST;

    or
    private final int first;

  6. Charles May 5,2017 9:34 am

    My favorite part of this question, is that this short question is worth %12.5 percent of the exam (Given that there are 4 FRQs worth 50% of the test).

  7. Pat May 5,2017 6:32 pm

    did I need to create a toString method for this problem

    • Brandon Horn May 6,2017 10:17 am

      No. If you wrote a toString method and it didn’t have a side effect I doubt you would be penalized though.

  8. Ibrahim May 6,2017 9:58 am

    will I get any points off if I forgot to put private?

    • Brandon Horn May 6,2017 10:15 am

      Historically, scoring guidelines have been pretty picky about making instance variables private. My guess would be that you would lose a point for it. (This is only a guess since the scoring guidelines haven’t been released yet.)

Comments are closed.