<< Chapter < Page | Chapter >> Page > |
This tutorial lesson is part of a series of lessons dedicated to the AP Computer Science A Exam .
The purpose of the series is to help you to better understand the Java Subset specifications for the Advanced Placement Computer Science A exam.
For example, if you access the AP Computer Science Course Description and scroll down to Appendix A titled AP Computer Science Java Subset , you will find the following specification :
3. The increment/decrement operators ++ and -- are part of the AP Java subset.
These operators are used only for their side effect, not for their value.
That is, the postfix form (for example, x++) is always used, and the operators are notused inside other expressions.
For example, a[x++] is not used.
(Note that I entered some line breaks into the above specification for clarity. Also note that this is the wording that appeared on the website on March 3,2011. It may change over time.)
May be clear to some, but not to others
While some students and their homeschool parents may know exactly what is meant by this specification, others may not. Therefore, my objective will be to elaborateon and attempt to clarify the specification from a technical viewpoint to help those students and their parents get a better understanding of where they need toconcentrate their efforts.
In this lesson, I will provide program code that illustrates some of what the student is expected to know. I will also provide program code to illustrate whatthe student is apparently not expected to know.
I recommend that you open another copy of this document in a separate browser window and use the following links to easily find and view the figuresand listings while you are reading about them.
I recommend that you also study the other lessons in my extensive collection of online programming tutorials. You will find a consolidated index at www.DickBaldwin.com .
In this section, I will present and explain sample programs that illustrate what the student does need to know and what the studentapparently doesn't need to know.
Let's begin with a question. What output is produced by the program shown in Listing 1 ?
Listing 1 . Simple increment/decrement. |
---|
public class Increment01{
public static void main(String args[]){
new Worker().doWork();}//end main()
}//end class definitionclass Worker{
public void doWork(){int w = 5, x = 5;
double y = 8.3, z = 8.3;w++;x--;
y++;z--;System.out.println(w + " " +
x + " " +y + " " +
z);}//end doWork()
}//end class definition |
Notification Switch
Would you like to follow the 'Ap computer science a, clarification of the java subset' conversation and receive update notifications?