Mr. Rogers AP Computer Science A - Second Quarter Objectives |
Essential Question: Do we live in a binary world? |
Chapter 7: Boolean Expressions and Conditional Control
Define conditional control.
Correctly use both if and if-else statements. (Be as one with the four Common if-else Errors on p. 156.)
Draw flowcharts for both if and if-else statements.
Correctly use boolean relational operators. == , > , < , >= , <= , !=
Correctly use boolean logical operators. && , || , !
Given a set of logic gates write the associated boolean expression (p. 3).
Write truth tables for "and", "or", and "xor" gates.
Evaluate complex boolean statements using correct order of operators (p. 163).
Correctly describe and use short-circuit evaluation.
Correctly use if-else-if tables for menus and selection processes like tax tables.
Correctly use switch statements. (Be as one with the six points on p. 197)
Test: Chap 1 & 2 Objectives 1-29
Essential Question: How can we access and perform similar manipulations on millions of volatile pieces of similar information without having to create millions of lines of code? |
Chapter 8 Iterative Statements (Loops)
- initialization
- testing
- incrementing
- even/odd numbers
- factorials
- fibonacci numbers
Test: Chap 8 Objectives 1-12
Essential Question: Why use objects instead of just using variables? |
Chapter 9: Implementing Classes and Using Objects
Properly declare a class.
Explain why fields are usually declared private and methods public.
Correctly declare and initialize (generally with the new operator) objects
Be as one with the nature of methods.
must be called to run
run sequentially from top to bottom unless branched
can be called repeatedly
when finished returns control of the program to the place the method was called.
contain a small highly focused program or algorithm.
modular and reusable
defined in a class
a form of control abstraction in which a single line of code, calling the method, can be used to perform a useful function without having to know all the details of how the method's code is written.
static (called by a class name) or instance (called by an instance)
Correctly write the header which declares a method inside a class.
access (public or private) returnType methodName (type parameterName1, ... type parameterNameN)
Explain the terms precondition and post condition as they relate to methods and procedural abstraction.
Explain how assertions and runtime exceptions are used in debugging, especially for reusable code.
Correctly use comments with method declarations so that a programmer could use the method without knowing the details about how the code is implemented.
Explain the nature of parameters.
creates a local variable inside the method
used for passing values into the method
when using objects can also pass a value out of the method
Explain the difference between an argument and a parameter.
Correctly use overloaded methods. (Same name different arguments)
different numbers or types of parameters
return type must be the same.
Correctly use constructers.
name is identical to the class name
no return type, not even void
can be overloaded
not required
Correctly use copy constructors.
State when the default constructer runs and how it initializes fields.
numbers = 0
booleans = false
references = null
Correctly use the "final" reserved word.
Correctly initialize objects and use the new operator (p. 224).
Homefun: read Sections 9.1 - 9.5; Exercises 1-6
State which type of fields can be accessed and what type methods can be called using a static method. (p. 223).
can access static field - only one value & one memory address
can call static method
can access instance field of a different class
can call instance method of a different class
State which type of fields can be accessed and what type methods can be called using an instance method (p. 223).
instance field - Many values & memory addresses. A field has one value per object
static field - Only one value & memory address
instance method
static method
Correctly call both static and instance methods (p. 226).
Use class name & dot operator when calling static methods from another class.
Use object & dot operator when calling instance methods from another class.
Class name & dot operator are optional when calling static methods in a class.
Use "this" & dot operator or nothing when calling instance methods in a class.
Compare the two ways to pass arguments to methods and constructers (p. 230).
Primitive data types are always passed as values--the variable containing the value and the value ceases to exist after the method has run
Objects are always passed as references--the address of a memory location that continues to exist after the method has run.
Correctly use return statements.
Test: Chap 9 Objectives 1-20
Essential Question: How can we store and manipulate not just numbers but human text in a computer program? |
Chap. 10 Strings
- String ()
- String (String s)
- String s1 = " "; //s1 is set to an empty String
- String s2 = new String(); //s2 is set to an empty String
- String s3; //s3 is set to null
- length()
- charAt (pos) //Note that characters are counted starting at 0.
- substring (pos)
- substring (fromPos, toPos)
- compareTo (s2) //returns neg int if s1 <s2, 0 if s1 = s2, pos int if s1>s2
- compareToIgnoreCase (s2) //returns neg int if s1 <s2, 0 if s1 = s2, pos int if s1>s2 ignoring case
- equals(s2) //returns a boolean true or false
- equalsIgnoreCase(s2) //returns a boolean true or false ignoring case
- indexOf (ch) //four types
- lastIndexOf (ch) //four types
- trim() //removes white space characters from beginning and end of string
- replace (oldChar, newChar)
- toUpperCase()
- toLowerCase()
- yourString += str;
- yourString = yourString1 + str;
- yourString.concat (str);
examples
Integer.parseInt(yourString)
String.valueOf(yourNumber)
Test: Chap 10 Objectives 1-13
Essential Question: How does OOP development using Java compare with the process of writing a book using English? |
Chapter 11: Class Hierarchies and Interfaces
- Example declaration:
- public abstract int tax(); // Note that there is no code, not even brackets.
- Example declaration:
- public abstract class People {
- . . .
- }
- Example declaration:
- public interface Career {
- . . .
- }
Has no abstract methods.
- A class can only extend one class but can implement multiple interfaces.
- Interfaces make code readable a uniform by standardizing terms (fields) and procedures (methods).
- a superclass's constructors must be used to initialize private fields
- a superclass's constructors can be called inside the subclasses constructor using super (<appropriate arguments>);
- if the superclass's constructor is not called the no-arguments-constructor of the superclass is run by default
- if there is not a no-arguments-constructor, an error message results
Homefun: Exercises 1-5
Programming assignments: 6a
Test: Chap 11 Objectives 1-15
Essential Question: How can we store millions of volatile pieces of similar information without having to create millions of variables in a computer program? |
Chap. 12 Arrays and ArrayLists
- int scores [ ] = new int[5];
- int scores [ ] = { 93, 67, 99, 87, 91};
- numbers = 0
- boolean = false
- objects = null
- final int ROWS = 2;
- final int COLS = 3;
- double name2DArray [ ] [ ] = new double [ROWS][COLS];
- or
- double name2DArray [ ] [ ] =
- {
- {0.0, 2.7, 5.6},
- {4.3, 1.4, 7.2}
- };
- twoDArray.length gives the number of rows
- twoDArray[0].length gives the number of columns
- Name Salary $1000/yr
- Bob Arnold 90
- Herb Bobo 12
- Jane Cool 27
- Alfred Nameless 49
- Juan Smith 200
- Betty Taylor 142
Next, output the total of all salaries. Use a random number generator to fire two employees. Remove them from the Array List then add a new employee called Bob Newguy with a salary of $200,000. Again, output a table with the names of the current employees and their salaries. Also output the total of all salaries.
Note: You need to write the letters on graph paper or in an Excel spread sheet in order to understand how many spaces are needed. To understand how the arrays should be initialized look at chapter 10 objective 7 above. You do not need to reproduce the grid lines in your program's output.
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
0 | A | ||||||||||
1 | A | A | |||||||||
2 | A | A | |||||||||
3 | A | A | A | A | A | A | A | ||||
4 | A | A | |||||||||
5 | A | A |
Test: Chap 12 Objectives 1-16