The AP Java Subset - PowerPoint PPT Presentation

About This Presentation
Title:

The AP Java Subset

Description:

The AP Java Subset Topics Primitive Types int double boolean Operators +, -, *, /, % ++, -- = +=, -=, *=, /=, %= ==, !=, , = &&, ||, ! Numeric Casts (int ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 42
Provided by: rebeccag171
Category:
Tags: java | math | subset | topics

less

Transcript and Presenter's Notes

Title: The AP Java Subset


1
The AP Java Subset
  • Topics

2
A Topics
3
Primitive Types
  • int
  • double
  • boolean

4
Operators
  • , -, , /,
  • , --
  • , -, , /,
  • , !, lt, gt, lt, gt
  • , , !

5
Numeric Casts
  • (int)
  • (double)

6
String Concatenation
  • will convert numbers to strings and invoke the
    toString() method on objects

7
Escape Sequences
  • \\
  • \
  • \n

8
Input Output
  • INPUT IS NOT TESTED
  • Output is restricted to System.out.print and
    println
  • Formatting output is not tested

9
Arrays
  • One-dimensional
  • Arrays of primitive types of objects
  • Initialization of named arrays
  • int array 1, 3, 6, 9

10
Control Structures
  • if
  • if/else
  • while
  • for
  • return
  • (do/while, switch, continue, break not tested)

11
Method Overloading
  • Understand signature of method
  • Depends on number, types order of parameters
  • Does not depend on return type of method

12
Classes
  • Construct objects with new operator
  • Supply constructor parameters
  • Invoke accessor modifier methods
  • Modify existing classes
  • Design own classes

13
Visibility
  • All classes will be public
  • All instance variable will be private
  • Methods, constructors and constants are either
    public or private
  • NO protected

14
Comments
  • // single line comments
  • / / block comments
  • No Javadoc comments

15
Final Static
  • final keyword is used for final block scope
    constants
  • static final class scope constants
  • static methods
  • static final variables
  • NO final parameters, final methods, final
    classes, static variables

16
null this
  • null reference is in the Java subset
  • this is restricted to passing an implicit
    parameter in its entirety to another method
    (obj.method(this))
  • Descriptions such as the implicit parameter this

17
Super
  • Use to invoke superclass constructor
  • ex super(args)
  • Or to invoke superclass method
  • ex super.method(args)

18
Constructors
  • Be able to implement
  • Initialize all instance variables
  • Dont need to know default rules

19
Extend Implement
  • extend classes
  • implement interfaces
  • Know inheritance!!!

20
Read and Understand
  • Be able to read definitions of interfaces and
    abstract classes
  • Understand that the abstract methods need to be
    redefined for non-abstract classes
  • Write interfaces or class declarations when given
    a general description of the interface or class

21
Equals
  • Know when to use or .equals
  • Objects equals
  • Identity

22
Subclass to Superclass
  • No casting is needed to convert from a subclass
    to a superclass
  • Do need to know class casts
  • ArrayList xx new ArrayList()
  • yy (yyclass)xx.get(i)

23
Packages
  • import statement
  • import package.subpackage.class

24
Exceptions
  • NullPointerException
  • ArrayIndexOutOfBoundsException
  • ArithmeticException
  • ClassCastException
  • IllegalArgumentException

25
Standard Library Methods
  • java.lang.Object
  • equals
  • toString
  • java.lang.Comparable
  • compareTo
  • java.lang.Integer
  • Integer(int value) //constructor
  • intValue
  • equals
  • toString
  • compareTo

26
Standard Library Methods (contd)
  • java.lang.Double
  • Double(double value) //constructor
  • doubleValue
  • equals
  • toString
  • compareTo
  • java.lang.String
  • compareTo
  • equals
  • length
  • substring
  • indexOf

27
Standard Library Methods (contd)
  • java.lang.Math
  • abs (for int and double)
  • pow
  • sqrt
  • java.util.Random
  • nextInt
  • nextDouble

28
Standard Library Methods (contd)
  • java.util.ArrayList
  • size
  • add
  • get
  • set
  • remove

29
AB Topics
30
Two-dimensional Arrays
  • Ragged arrays are not tested
  • int x new int3
  • Dont need to know int33 is an array of
    arrays
  • Know that x0.length is the number of columns in
    a rectangular two-dimensional array named x

31
Abstract Classes
  • AB students are expected to design own interfaces
    and abstract classes

32
Throwing Unchecked Exceptions
  • IllegalStateException
  • NoSuchElementException

33
Standard Library Methods
  • java.lang.Object
  • equals
  • toString
  • hashCode
  • java.lang.Comparable
  • compareTo
  • java.lang.Integer
  • Integer(int value) //constructor
  • intValue
  • equals
  • toString
  • compareTo

34
Standard Library Methods (contd)
  • java.lang.Double
  • Double(double value) //constructor
  • doubleValue
  • equals
  • toString
  • compareTo
  • java.lang.String
  • compareTo
  • equals
  • length
  • substring
  • indexOf

35
Standard Library Methods (contd)
  • java.lang.Math
  • abs (for int and double)
  • pow
  • sqrt
  • java.util.Random
  • nextInt
  • nextDouble

36
Standard Library Methods (contd)
  • java.util.List
  • add
  • size
  • get
  • set
  • iterator
  • listIterator
  • java.util.ArrayList
  • All List methods
  • add
  • remove

37
Standard Library Methods (contd)
  • java.util.LinkedList
  • addFirst
  • addLast
  • getFirst
  • getLast
  • removeFirst
  • removeLast

38
Standard Library Methods (contd)
  • java.util.Set
  • add
  • contains
  • remove
  • size
  • iterator
  • java.util.HashSet
  • java.util.TreeSet

39
Standard Library Methods (contd)
  • java.util.Map
  • put
  • get
  • remove
  • containsKey
  • size
  • keySet
  • java.util.HashMap
  • java.util.TreeMap

40
Standard Library Methods (contd)
  • java.util.Iterator
  • hasNext
  • next
  • remove
  • Java.util.ListIterator
  • add
  • set

41
Online resources
  • Acorn online
  • Java API
Write a Comment
User Comments (0)
About PowerShow.com