7th Period AOIT Study Guide
What will be the output of the following for() loop? for (int i=0; i<10; i+=3){ System.out.print(i * 3 + " ");}
0 9 18 27 36
Flowcharts showing branching algorithms will have at least one of what symbol?
A diamond
What best describes a syntax error?
A syntax error happens when the compiler finds one more invalid
What do you call a method that safely returns a copy of private data to external code?
An accessor method
What symbol would you add to a flowchart to show the program flow between othershapes?
An arrow
What kind of tool do you need to create a flowchart?
Any software that lets you use shapes
What happens when you try to perform an integer divide-by-zero operation?
ArithmeticException
Why can the JVM always run the main() method on a class without creating an object from that class first?
Because the main() method is static
What best describes the purpose of the "continue" statement?
Causes the next loop iteration to start
If you decide to copy your pseudocode into a Java source file what should you do with the resulting pseudocode
Comment it
What symbol would you add to a flowchart to show a decision that needs to be made?
Diamond
output? String input = "Donnybrook"; for (int i=0; i<input.length(); i+=2) { System.out.print( input.charAt(i) );}
Dnryo
In OOP, what does the concept of "coupling" describe.
Each copy is called an object or instance
If you don't want external code to change your class data to unexpected or invalid values, and you want the freedom to redesign your internal variables without breaking external code, what OOP concept should you use?
Final
What type of loop would you use if you want a numeric index and know how many times the loop should run?
For() loop
In programming, what do we call the process of breaking a larger task down into a series of smaller, well-defined parts?
Functional Decomposition
How do you access a public, non-static property defined on a class from some code outside that class?
Have an instance calling the non-static property.
For an interface named ITranslatable, which of the following is a valid Java filename for that interface?
ITranslatable.java
When is a do-while() loop usually a better choice than a while() loop?
If you want the loop body to complete at least once
Where do you declare variables with "local" scope?
Inside a function
A programmer has defined the following constructor method for the Spaghetti class. What is wrong with this constructor definition? private void Spagh()
It needs to be the same name as the class
If a static property is marked as private, what kind of method lets external code update that property?
Mutator method
What do we call a method that will update a private property after verifying the incoming data is valid?
Mutator method
What kind of class property is copied and uniquely owned by each object created from that class?
Non-static
The exceptions that happen when you try to call a method on a null reference variable
NullPointer Exception
If you have marked a method as "private", where can that method be called from?
Only inside of the class
What design tools contain a rough outline of your code, without any Java syntax rules?
Psuedo Code
What symbol would you add to a flowchart to show a specific step your algorithm will take?
Rectangle
What does the term "nested" mean when used to describe blocks of Java code?
Refers to blocks of code inside other blocks of code
In OOP, what does the concept of "cohesion" describe?
Revolves around the creation of re-usable code
Given a Java source file named "Spaghetti.java", you can be confident the class inside has what name?
Spaghetti
What kind of class property is shared simultaneously between all objects created from that class?
Static
Given the following code, what variable name must be used where the loop index ??? is marked? for (int ??? = 0; ???<10; ???++)
The index variable
When a for() loop ends, where does the program flow continue?
The program flow continues right after the loop.
Given the exception message below, what can you tell about the nature of the exception? (Exception in thread "main" java.lang.NullPointerException at Mystery.main(Mystery.java.:11).)
There is a NullPointer exception in line 11 in Mystery.main Java.
How do you access a public, static property defined on a class from some code outside that class?
Through the class name
When writing exception-handling code, what block goes first? Try or Catch?
Try
What best describes the number of times a while() loop body will run?
Until the logical expression is false
Given the following method declaration on the Spaghetti class, which answer best describes how other classes can access this method? private void boil();
Use a method that uses that method
If your program has no syntax errors and no exceptions, what else could go wrong?
You created a logical error, which means your code is not doing what you want it to do.
When an exception happens in your main() method, what happens if no other exception-handeling code has been added?
Your program immediately halts
The algorithm to find the position of a substring within a larger string is implemented by what Java String class method
charAt()
Given the Spaghetti class declaration below, which answer describes how other classes can access the Spaghetti class?
class Spaghetti
Assuming the Spaghetti class has a method declared as follows... public void boil()... then given the following line of code, which answer will correctly call the boil() method on the object? Spaghetti dinner = new Spaghetti();
dinner.boil()
Which condition allows you to us a for loop to create a single index which compares strings without exceptions?
i <= str.length()
What main decision and action are used inside a loop which counts occurences of one character
if (i = [current character]) { i +=1 }
If you want to use the short name for the "Spaghetti" class in the food.paste package, what goes at the top of the code
import food.pasta.Spaghetti
Output? String input = "Donnybrook"; for (int i=input.length() - 1; i >= 0; i--) { System.out.print
koorbynnoD
If a Spaghetti class defines a property named "sauce" that is a reference to a PastaSauce object, then what value is stored in the "sauce" property after the following code is run (assuming there is only a default constructor)? Spaghetti dinner1 = new Spaghetti();
null