<< Chapter < Page Chapter >> Page >
Provide program code that illustrates some of what the student is expected to know about the increment/decrement operators. Also provides program code to illustrate some of what the student is apparently not expected to know.

Table of contents

Preface

General

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.

Viewing tip

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.

Figures

  • Figure 1 . Behavior of increment operator.
  • Figure 2 . Behavior of decrement operator.

Listings

Supplemental material

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 .

Discussion and sample code

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.

What the student apparently does need to know

Let's begin with a question. What output is produced by the program shown in Listing 1 ?

  • A. Compiler Error
  • B. Runtime Error
  • C. 5 5 8.3 8.3
  • D. 6 4 9.3 7.300000000000001
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

Questions & Answers

a perfect square v²+2v+_
Dearan Reply
kkk nice
Abdirahman Reply
algebra 2 Inequalities:If equation 2 = 0 it is an open set?
Kim Reply
y=10×
Embra Reply
if |A| not equal to 0 and order of A is n prove that adj (adj A = |A|
Nancy Reply
rolling four fair dice and getting an even number an all four dice
ramon Reply
Kristine 2*2*2=8
Bridget Reply
Differences Between Laspeyres and Paasche Indices
Emedobi Reply
No. 7x -4y is simplified from 4x + (3y + 3x) -7y
Mary Reply
is it 3×y ?
Joan Reply
J, combine like terms 7x-4y
Bridget Reply
im not good at math so would this help me
Rachael Reply
how did I we'll learn this
Noor Reply
f(x)= 2|x+5| find f(-6)
Prince Reply
f(n)= 2n + 1
Samantha Reply
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
can nanotechnology change the direction of the face of the world
Prasenjit Reply
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
Ali Reply
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
bamidele Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Got questions? Join the online conversation and get instant answers!
QuizOver.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Ap computer science a, clarification of the java subset. OpenStax CNX. Oct 03, 2015 Download for free at https://legacy.cnx.org/content/col11279/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ap computer science a, clarification of the java subset' conversation and receive update notifications?

Ask