Advancing Engineering with AI through the Next Generation of Strategic Projec...
Some tips for taking the High School AP Java college board exam
1. Some last-minute tips for taking the high school
Java AP Exam
For 2021 Spring.- short tips for the college board exam
1) Look over “hello world” example
main is all lower case and must be in the top level class in the program
String [] is an array and you must use the []
args is dummy and can be any name
(it's static so its there from the start)
2) Look over what is a valid variable name
convention is to start with a lowercase letter, (you can start $ or _ but not recommended)
(variables cannot start with arithmetic operator +_*/ or % as they would trip up the parser confusing
with arithmetic ) Reserved words may not be used including some not currently used like “goto”
1000 and 1_000 are both valid and the same. The underscore can be added to a number for
readability but not at start or end or next to decimal, its used like a comma to make the number readable
and is stripped out.
3) All keywords are all lower case (public static void main, true false and primitive types)
Classes start capital, constants all uppercase Math.PI Math is a class PI is constant as example
4) Do not return anything for a constructor and there is no type (not even void)
5) do not print anything they don't ask In general don’t spend time doing anything not asked
6) Assignments will shove data over for primitives (a new clone) but share a reference for objects
(and will be aliases of the same thing). a=b will shove b into a as a copy for primitives but is a
reference for objects like String or ArrayList or Array While primitives will deal with a copy, object
assignments is like handing a voodoo doll and whatever you do with a will affect b
7) Check the cheat sheet they give you (as much as possible) especially if the case uses property
length as used in Array, method length() as used in String or size() as used in ArrayList and
collections in general
8) Think whether the method changes the original or returns a change. Sometimes a method
leaves the original unchanged and the change is only in the return (they might try and trick you in a
multiple choice on that)
9) Mult-dimensional arrays are row major meaning row then column array[row][column]
10) The graders are friendly and want to find ways to give you points so make your code readable, mark
with comments which parts apply to the questions parts if it makes it readable. Give them opportunity to
give you part credit. Write code that is easy to read, comment for emphasis for you address the question
parts
Array may be multi-dimensional (is iArray int{10][10{ iArrayList ArrayList<Integer> is single
dimensional
2. 11) Datatypes defaults for literal numbers are integer and double
a constant 1 would be int 1.0 would be double
assigning something larger to smaller like float <-- double or int <--- long will cause an error
you can however cast things like byte a = (byte) b ; long as the data is not too big for the variable
that contains it
Java has no unsigned type as there is in C C== or C# that you need to worry about for this test.
Byte will be -127 to +127
Short will be about -32k to +32k
Int will be about -2G to +2G
Integer.MAX and Integerrimine for example are static constants you can use on that
(inJava,the number1 isnot true and 0 isnot false.Integers andBooleanare separate datatypes)
12) Classesyou can only have1 parent but can implementmanyinterfaces. There is no multiple
inheritance forclassesinJava. Onthe otherhand,you can implementmultiple interfaces(youcan
considermultiple requirementsYou canthinkof Object-orientedprogrammingashierarchical
programming.
You can have abstract interfacesand abstractclasses(an abstract class anotherwayof implementinga
requirement) Youcannotconcretize them, makinganobjectuntil all the abstractmethodsare
implementedinanon-abstractclass