Jump to page content Jump to navigation

College Board

AP Central

AP Exam Reader
Siemens Awards for Advanced Placement

APAC 2010
Print Page
Home > AP Courses and Exams > Course Home Pages > Java 1.5: Where Does It Fit into AP Computer Science?

Java 1.5: Where Does It Fit into AP Computer Science?

by Mark Weiss
Florida International University
Miami, Florida

With the beta version of Java 1.5 available, many AP students and teachers are wondering how this will affect the responses (or scoring of responses) on the AP Computer Science Exam. In the spring of 2004, before the first APCS Exam using Java, Mark Weiss, AP CS Development Committee chair, addressed several of these issues in an email posted to the AP CS Electronic Discussion Group (EDG). What appears below is a summary of Mark's comments.


The "Java subset" simply discusses the parts of the language that are testable. As such, things such as main, nontrivial I/O, StringTokenizers, StringBuffers, chars, and others that are not in the subset are simply not constructs that will appear on the exam, although it is expected that many of these topics will be covered in an AP CS course.

The 2004 AP CS Exams were written before Java 1.5 was available. In fact, though available for download, Java 1.5 is still in beta form. In some ways, 1.5 is very appealing. But some features of 1.5 being discussed via the EDG can be very confusing to AP teachers who are just managing to stay a bit ahead of their students (in 1.4). Other teachers are embracing 1.5, having students download and experiment with it. For these teachers, there are concerns about the grading of the AP Exams and teaching of future AP CS courses.

Java 1.5 Issues
1. What happens if students use Java 1.5 constructs on the 2004 AP CS Exam?

2. What effect will Java 1.5 have on the exam in the future?

With regard to the first issue, in the days of C++, the policy had been that when students wrote code outside of the subset, if the code was correct, it counted. But if the code was not correct, then points would be deducted. However, this rule was changed on the 2003 AP CS Exam with the introduction of the design question. There, legal but poorly designed code earned deductions.

When the exam questions are being formulated, the Development Committee, along with the Chief Reader, discusses the expectations of the students, possible grading difficulties, and various alternate solutions. The ultimate decisions of point deductions are made at the Reading by the Chief Reader in consultation with experienced exam leaders.

On the 2004 exam, good design will be enforced further. Two specific items regarding design can be seen in the sample questions in the Course Description.

General Design Issues
1. Code that replicates already written code in a method, instead of invoking an appropriate already written method, is an example of legal but poorly designed code that will merit deductions of points.

2. Code that creates unnecessary instances of collections classes may merit deductions of points. For instance, if we ask for code to print the contents of a Set, the following legal code may lose points:

    public static void print( Set s ) 
    {
        ArrayList copy = new ArrayList( s );  
				// constructor not in AP subset
           for( int i = 0; i < copy.size( ); i++ )
               System.out.println( copy.get( i ) );
    }  
	


Here, the deduction would not be because of the use of the constructor that is outside of the subset; rather, it is the creation of an unnecessary ArrayList. Though some students may see this as more easily understood, the creation of this collection is unnecessary if the choice to use a Set iterator was made.
public static void print (Set s)
{
   Iterator iter = s.iterator()
   while iter.hasNext()
	System.out.println(iter.next());
}


A more interesting comment was made by Owen Astrachan. What happens to the student who uses the correct Java 1.5 code below in a solution to the same question?

public static void print( Set s )
{
     for (Object o : s) System.out.println(o);
}


Since this is correct Java 1.5 syntax for a generalized for loop, this code would be acceptable.

The Development Committee has decided to address the two design issues in the sample questions of the Course Description. The rules for these two specific items (stated in Design Issues 1 and 2 above) will be made explicit on each of the 2004 exam questions, will be moved to the preamble on the 2005 exam, and will be implicit on the 2006 exam.

What happens if students use Java 1.5 constructs on the 2004 AP CS Exam?
With respect to code that uses Java 1.5 on free-response questions for the 2004 AP CS Exam, you can expect the same general rules to apply:

  • Use of a generic API class is acceptable.
  • Use of boxing/unboxing is acceptable.
  • Use of a generalized for loop, if done correctly, is acceptable.
General Exam Grading
The questions are written so that solutions are easily accessible within the subset. It is true that reasonable correct use of API methods that are not listed in the subset will not incur deductions. However, it should also be noted that the Java API is much larger than C++, and that Readers are only human. A student who uses an obscure construct from the API, even if done correctly, risks having the Reader miss subtleties and perhaps score the problem incorrectly. It is always safer to stick with the subset and to keep the code simple!

When scoring free-response questions, the general policy has always been to ignore some trivial syntactic errors, such as missing semicolons, or braces when the indenting of the code makes the intent clear. It is always in the best interest of the students not to rely on this, as it is sometimes tricky where to draw the line. For instance, if we ask students to write an interface, and they list a method as:
  public interface Fooable
  {
    void foo( ) { }  // Oops... no implementations allowed!
  }
is this considered a deductible error? Very tough call here, that will be made at the Reading by a team of experienced Readers.

What effect will Java 1.5 have on the exam in the future?
With regard to the AP CS subset, Java 1.5 is still in beta, so any subset changes are clearly premature, and any changes made would definitely not be reflected on the 2004 or 2005 AP Exam. Once Java 1.5 is finalized, the Development Committee will want to consult with colleges to best assess how they will treat Java 1.5 and will base their decisions partly on the feedback they receive.

A description of some of the new features are at http://java.sun.com/features/2003/05/bloch_qa.html



Some preliminary discussion has taken place among the Committee members. Below are some of the Committee's general feelings categorized as most likely to be included, least likely to be included, and most likely to be difficult to decide. However, these are NOT final decisions and will be revisited/refined as more information about 1.5 and college use becomes known.
  • Most likely to be included: Use of generic API classes is the most likely Java 1.5 construct to be added to the subset. The baggage on this is relatively minimal, and it makes the questions easier to read by removing lots of casting and making it clear which types are being stored in the collections. For instance, in our questions we could declare types such as List<String>, Map<String,Integer>, and even Map<String,List<String>>. Students will probably find it easier to write code using the generic API classes. We would limit the scope of this in the simplest possible way.

  • Least likely to be included: The enhanced for loop, typesafe enum, and static import directives are the least likely Java 1.5 constructs to be added to the subset. We do expect students will use the enhanced for loop on free-response solutions, but the additional syntactic sugar does not seem warranted to simply eliminate a simple line of code. The typesafe enum would seem to have lower priority than char, which is not in the subset now. And the static import directive seems like a very inappropriate construct for an introductory course.

  • Most likely to be difficult to decide: Java 1.5 constructs on the borderline for subset addition, and likely to require the most discussion, are the implementation of generic classes and autoboxing. Unlike using generic classes, implementation of generics is fairly tricky, and it is possible that implementation of generic classes won't be in the subset at all. If implementation of generic classes is in the subset, only an extremely small portion of the fairly complex rules would likely be in the subset. Autoboxing makes some questions read more nicely and makes some code easier to write, but on the other hand, it means more material for teachers to discuss, possibly with obscure rules, with relatively little payoff.

Mark Allen Weiss is a professor in the School of Computer Science at Florida International University in Miami, Florida. He received his bachelor's degree in electrical engineering from the Cooper Union in 1983, and his Ph.D. in computer science from Princeton University in 1987, working under Bob Sedgewick. He has been at FIU since 1987, and was promoted to professor in 1996. His interests include data structures, algorithms, and education, and he is most well-known for his highly-acclaimed Data Structures textbooks, which have been used at hundreds of universities worldwide. He has served as member and chairperson of the Advanced Placement Computer Science Development Committee and has been a Reader for the AP CS Exam.


  ABOUT MY AP CENTRAL
    Course and Email Newsletter Preferences
  AP COURSES AND EXAMS
    Course Home Pages
    Course Descriptions
    The Course Audit
    Sample Syllabi
    Teachers' Resources
    Exam Calendar and Fees
    Exam Questions
    FAQs
  PRE-AP
    Teachers' Corner
    Workshops
  AP COMMUNITY
    About Electronic Discussion Groups
    Become an AP Exam Reader

Back to top