JAVA FINAL 16

¡Supera tus tareas y exámenes ahora con Quizwiz!

What must every line of code not followed by curly braces end in?

";"

grouping operator

( ), highest precedence

{ }

(Curly braces). Marks the beginning and end of a unit, including a class or method description.

Named constant:

A memory location whose content is not allowed to change during program execution.

Binary operator:

An operator that has two operands.

&&

And(both are true)

Layering Reader Classes

BufferedReader in = new BufferedReader( new FileReader(path))

ALL UPPERCASE IN JAVA

CONSTANTS

Inheritance

How one class can be created from another.

A variable declared in a method is said to be a ____________________.

Local variable

return type of constructor

NONE...not even void

Assignment operator:

The = (the equals sign). Assigns a value to an identifier.

println

a method that prints characters to the screen and moves to the next line

Virus

a program that can enter a computer and perhaps destroy information

public class _____

class header; indicates a publicly accessible class named "_____"

get a file

import java.io.* public static void getAFile(String filename) { try{ FileInputStream file = new FileInputStream(filename);} }

access modifier

says where a class can be used or referenced

public interface Pet

syntax to create an interface called Pet

String combination identifier

"+"

How do you assign data to a variable?

"=". ex. int number = 100

When defining a method, the _____ parameter is a name used for the calling object.

"this."

remainder or modulus operator

%, fourth highest precedence, left to right association

way to genericize new Fragment();

(TO) createFragment() take constructor form and replace with function to genericize (refactor)...but either have to define function right there, or create abstract stub, making class abstract

cast operator

(double),(int), third highest precedence, right to left association

s is a string. Expression whose value is true if & only if the value comes bw "mortgage" & "mortuary" in the dictionary.

(s.compareTo("mortgage") > 0 && s.compareTo("mortuary") < 0 )

Cast

(typeName) expression

assign userInput to a variable

(within if statement) int numberEntered = userInput.nextInt(); ...also Line, Boolean, Float

What operator multiplies two numbers?

*

multiplication operator

*, fourth highest precedence, left to right association

addition operator

+, fifth highest precedence, left to right association

unary plus operator

+, third highest precedence

pre-test loops

- for construct - while construct

subtraction operator

-, fifth highest precedence, left to right association

unary minus operator

-, third highest precedence

Mixed Mode Conversion

-Convert to LARGEST DATA TYPE -does not allow from more accurate to less accurate

post-test loop

-do while construct

switch construct

-expr must eval to char, byte, short or int types -case values must be literals/constants + unique -include BREAK after case

method selector operator

., second highest precedence, left to right association

How to use sub-string function?

...

equals upper or lower case

.equalsIgnoreCase()

other scanner (static) object methods

.hasNextBoolean() .hasNextFloat() .hasNextDouble()

What operator divides two numbers?

/

division operator

/, fourth highest precedence, left to right association

What symbols are used to make comments in Java? (Both single and block comments)

// and /* */

boolean

1 bit primitive that manipulates the two logic value T and F.

byte

1 byte, stores an integer

What are checked & unchecked exceptions.

1) Checked Exception is required to be handled by compile time while Unchecked Exception doesn't. 2) Checked Exception is direct sub-Class of Exception while Unchecked Exception are of RuntimeException.

interfaces vs abstract class

1) abstract class and interface cannot be instantiated...a class implements an interface, or an interface extends an interface, but an interface cannot implement an interface. 2) an interface specifies a "contract", and all method stubs must be implemented (or at least overridden in subclass) 3) public and abstract are automatically added to every interface method, and abstract is implicitly (& automatically) added to entire interface. 4) in interface, NO method is allowed to have a body

2 main benefits of abstraction

1) good design, 2) (unintended) security in that hackers are not going to guess setCartesianCoordinates(integer x, integer y); but would rather first guess setX(integer x);

Name 3 reasons why favor composition over inheritance

1. Almost all inheritance can be rewritten 2. Less about modeling the real world and more about modeling interactions in a system and roles and responsibilities 3. Inheritance is difficult to maintain V52

Describe 2 classes can have.

1. Is a - inheritance 2. Has a - composition / aggregation V47

Create an array called 'colors' and add to it :"red","blue", "Green" 2. 1. Create a foreach loop the writes out the contents of the arra

1. String[] colors = new String[] {"red","blue", "Green"}; 2. for (String c : colors){ System.out.println(c); } v42

Name to things about strings in Java.

1. Treated like a primitive type (can be assigned w/o the New keyword) but it's an object 2. They're immutable (can't be changed). If you give a string a different value, it create an new string in memory. Java Fundamentals - v22

Reasons to use "double"

1023 digits after the decimal point

Reasons to use "float"

127 digits after the decimal point

short

2 bytes, stores integer values

int

4 bytes, stores integer values

float

4 bytes, stores less precise floating-point numbers

long

4 bytes, stores long integer values

What is the ASCII value of 'A'?

65

byte (signed) short (signed) int (signed) long (signed) float double char boolean

8 bits > -2^7 to 2^7 -1 16 bits > -2^15 to 2^15 -1 32 bits > -2^31 to 2^31 -1 64 bits > -2^63 to 2^63 -1

Byte

8 bits. smallest unit of storage in memory

double

8 bytes, stores floating-point numbers

What is the ASCII value of 'a'?

97

In Java, every program statement ends with what?

; (a semicolon)

What are 6 assignment operators?

= += -= *= /= %= ----------------- v20

Logical ops: !expr __ & __ __&&__ __^__ __ | __ __||__

= NOT (evaluates from RIGHT to LEFT) = logical AND' = conditional AND = logical exclusive OR (either not both) = logical inclusive OR = conditional OR

assignment operator

=, lowest precedence, right to left association

Instantiate

=new

Identifier:

A Java identifier consists of letters, digits, the underscore character ( _), and the dollar sign ($), and must begin with a letter, underscore, or the dollar sign.

key

A ____ is an identifier used to reference, or look up, a value in a data structure.

JDK

A bundled set of development utilities for compiling, debugging, and interpreting Java Applications.

What must a class name always start with?

A capital letter then camel case with no spaces.

Escape Sequences

A character preceded by a backslash is an escape sequence ~ \t = tab ~ \b = backspace ~ \n = new line ~ \r = carriage return

BufferedReader

A class. Read text from a character-input stream, buffering characters so as to provide for the efficient reading of characters, arrays, and lines.

Expression

A construct made up of variables, operators, and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value.

Screen coordinate system

A coordinate system used by most programming languages in which the origin is in the upper-left corner of the screen, window, or panel, and the y values increase toward the bottom of the drawing area

boolean

A data type that represents a true or false value.

double

A data type that represents decimals.

int

A data type that represents whole numbers.

DataSource

A factory for connections to the physical data source that this DataSource object represents.

Source file:

A file containing the source code, having the file extension .java.

Method

A group of programming statements given a name.

block

A group of zero or more statements between balanced braces and can be used anywhere a single statement is allowed.

What is a 'set' in Java?

A grouping like a LIST but all the items are unique. There are no duplicates.

What's a list in Java?

A grouping that is ordered, sequential & can have duplicates.

Variable

A location in memory used to hold a data value.

Variable:

A memory location whose content may change during program execution.

b()

A method called b

accessor method

A method that gets the value of an instance variable without altering the state of the variable/object.

Relative Path

A path that is not anchored to the root of a drive. Its resolution depends upon the current path. Example ../usr/bin.

Programming:

A process of planning and creating a program.

ResultSet

A public interface. A table of data representing a database result set, which is usually generated by executing a statement that queries the database.

An object is this type of variable

A reference variable

Computer program:

A sequence of statements whose objective is to accomplish a task.

Escape Sequence

A sequence used to represent special characters.

Programming language:

A set of rules, symbols, and special words.

Data type:

A set of values together with a set of operations.

Transistors

A solid state device that has no mechanical or moving parts; the light switch of electricity flow

Constructor?

A special type of method that is called when an object is created to initialize variables.

Assignment Statement

A statement assigning a value to a variable.

Register

A storage cell that holds the outcome of an arithmetic operation

Pseudocode

A stylized half-English, half-code language written in English but suggestion Java code

switch case vs if else

A switch compiles into a lookup table which is fundamentally different then the if/else statements. If the last statement in a if/else chain is the one you want you have to check all the previous if/else first. This is not the case with a switch

Attribute

A value an object stores internally.

Literal

A value represented as an integer, floating point, or character value that can be stored in a variable.

Object Reference

A value that denotes the location of an objection in memory. A variable whose type is a class contains a reference to an object of that class

Sentinel

A value that tells us to stop looping

The BitSet class also provides other methods for performing comparisons and bitwise operations on sets such as:

AND, OR, and XOR

name [row] [col]

Access an element

. operator

Access fields

1. A(n) -______- allows the application class to retrieve the value of an instance variable.

Accessor Method Call

Private instance variables can be accessed from outside their class through ______ methods and changed with _________ methods

Accessor methods && Mutator methods

J2EE

Acronym for Java 2 Platform, Enterprise Edition.

J2ME

Acronym for Java 2 Platform, Micro Edition.

J2SE

Acronym for Java 2 Platform, Standard Edition.

6. A(n) -______- is the value sent to a method.

Actual Parameter

Concatenation

Adding one string to another.

Scanner input = new Scanner(System.in);

Adds scanner to program

.java

All Java file names have to have this extension.

Capital Letter

All java file names must have this at the beginning.

Defining a variable

Allocates memory for storage

What are bounded types in Java?

Allows you to restrict the types that can be used in generics based on a class or interface. v60

StringBuffer

Alters immutability

Passing by reference

An Array is - it passes info about where the array is stored in memory

StackTraceElement

An element in a stack trace, as returned by Throwable.getStackTrace(). Each element represents a single stack frame. All stack frames except for the one at the top of the stack represent a method invocation. The frame at the top of the stack represents the the execution point at which the stack trace was generated. Typically, this is the point at which the throwable corresponding to the stack trace was created.

classpath

An enviroment variable that includes an argument set telling the Java virtual machine where to look for user defined classes/packages.

JRE

An environment used to run Java Applications. Contains basic client and server JVM, core classes and supporting files.

Run-time error

An error that occurs when a program asks the computer to do something that it considers illegal, such as dividing by 0

Mixed expression:

An expression that has operands of different data types.

Object

An instance of a class.

Unary operator:

An operator that has only one operand.

String Literal

Anything within double quotation marks.

18. A call to the toString method would appear in the -______-.

Application class

Methods?

Are always public. They return data. Methods are made so that you can call on them so that you can use its functionality.

Parameters are filled in with _________________ when invoking a method.

Arguments

exception types

ArithmeticException ClassNotFoundException IllegalArgumentException IndexOutOfBoundsException(s) InputMismatchException

ArrayList eg

ArrayList<String> names = new ArrayList(); names.add = "John Smith"; names.add = "Pete Wendell"; names.add = "Alicia James"; these are added just as they would be in an array, with John smith at index 0, pete at index 1... however, i can also do names.add(2, "Harvey Dent"); which must current 2 index to right...

20. A(n) -______- stores a value in a variable.

Assignment Statement

Declaring a variable

Associates variable's name with type ~DOES NOT ALLOCATE MEMORY FOR STORAGE

Name 9 primitive types

BSILF DB CS byte short int long float double boolean char String

Naming Methods?

Begins with public then is whatever data is going to be returned. ex. public String displayname()

Scope

Block of code in which a variable is in existence and may be used.

&&

Boolean operator meaning both sides have to be true. A Short circuiting logical operator.

||

Boolean operator meaning only one side has to be true. A Short circuiting logical operator.

int

By default, the int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. In Java SE 8 and later, you can use the int data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 232-1. Use the Integer class to use int data type as an unsigned integer. See the section The Number Classes for more information. Static methods like compareUnsigned, divideUnsigned etc have been added to the Integer class to support the arithmetic operations for unsigned integers.

What does the 'new' key word do here when creating an instance? Printer myPrinter = new Printer();

Calls the default constructor on the Printer class.

String

Can use +, ., and +=

Conversion

Changing one type of primitive data to another.

What are the TWO types of data contained by classes?

Characteristics and Behavior

16. The -______- contains the method header and the method body.

Class Method

RuntimeException

Class is the superclass of those exceptions that can be thrown during normal runtime of the Java virtual machine.

InterruptedException

Class. Thrown when a thread is waiting, sleeping, or otherwise paused for a long time and another thread interrupts it using the interrupt method in class Thread.

Object Construction

ClassName objectName = new ClassName(parameters);

Static method call

ClassName.methodName(parameters);

In OOP, describe is-a or has-relationships?

Classes in OOP, are related to each other & they're going to be related through an "IS-A" relationship or "HAS-A" relationship. > IS-A relationship result from inheritance > HAS-A relationship result from composition This comes from the need to reuse code. v47

ArrayList<Type>()

Constructor: Creates an empty ArrayList with an initial capacity of 10

ArrayList<Type>(int n)

Constructor: Initial capacity to hold n objects

Character types (char)

Contain single character value stored as unicode characters

new type [nRows] [nCols]

Create a 2D array

Instantiating

Creating an object

Instantiation

Creating an object.

Overloading the method?

Creating multiple definitions for the same method name, using different parameter types

14. The -______- specifies what information can be stored in a variable and what operations can be performed on it.

Data Type

Encapsulation?

Data and actions combined into a class whose implementation details are hidden

17. Instance variables are found in the -______-.

Declaration Statement

type[] [] name

Declare a 2D array

2. A(n) -______- is called when an object is instantiated and there are no arguments to be sent.

Default Constructor

Object-oriented programming

Designing a program by discovering objects, their properties, and their relationships

Operator precedence rules:

Determine the order in which operations are performed to evaluate an expression.

Static classes

Dont have instances

Surround all String text with?

Double Quotes

element

Each item in an array

What is camel casing?

Each time a new word begins start it with a capital letter

Primitive Data Types

Eight commonly used data types.

Double var = input.nextDouble();

Establishes value inputed into scanner as a variable

matrix.length pixels.length

Example of getting the number of rows

matrix[3] [2] = 8; pixels[r] [c] = aPixel;

Example of setting the value of elements

int value = matrix [3] [2]; Pixel pixel = pixels[r] [c];

Example: Accessing two elements

matrix[0].length pixels[0].length

Example: get the number of columns

int [] [] matrix Pixel [] [] pixels

Examples of 2D array declarations

new int [5] [8] new Pixel [numRows] [numCols]

Examples of creation of 2D arrays

a.b()

Execute a method b which belongs to object a

Exercise: 1. Create a printer class w/ a modelNumber property & a method to print that model #. 2. From you main method, assign a value to the modelNumber & invoke the Print() method.

Exercise. v(32)

Creating a File object

File f = new File(pathName);

Output Stream

Flows data from a program out to some external device

Input Stream

Flows data from some external device into a program

11. In a method header, the -______- specifies the type of data the method will send back to the caller.

Formal Parameter

name[0].length

Get the number of columns

name.length

Get the number of rows

joke about hacking into a bank without abstraction

Go to my account's global context and type setBalance()

What must variable names have/not have?

Have: Starts with a lower case letter. Not Have: after initial letter cannot have a symbol other than the underscore (no spaces).

Constants

Identifiers that always have the same value.

import java.util.Scanner;

Import the ability to use a scanner from database

Using Underscore Characters in Numeric Literals

In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal.

What is a primitive type in Java?

In java, we have primitive types & objects. Primitive types hold the actual value in memory. Object hold references in memory.

Static keyword

Indicates a class variable vs. an instance variable

3. A(n) -______- stores the data for an object.

Instance Variable

Objects have both _______ and _______.

Instance Variables && Methods

convert integer or any other type toString

Integer.toString(bigInt); Integer.parseInt(intString); -- this converts it back???

memory address register

It is 32 bits. Used in memory write and read operations and not accessible by the programmer.

What's the purpose of the Finally Block

It's useful to force code to execute whether or not an exception is thrown. It's useful for IO operations to close files.

;

Like a period in English. Marks the end of a statement or command

public static void main(String[] args){

Line 2 of program, opens programming block

LinkedList vs ArrayList

LinkedList compares favorably to ArrayList when adding and deleting objects from list a lot However, LinkedList is not as efficient at accessing ArrayList objects by index...when listening to video...he uses exact same methods on LinkedList as he did on ArrayList, so will have to check documentation (banas 12)

8. A variable that is declared inside a method and can only be used within that method is called a(n) -______- .

Local Variable

Define how java classes are connected.

Loosely connected objects that interact with each other.

Encapsulation

Making some data and methods inaccessible to outsiders ~public: visible anywhere ~private: visible only to other class members ~protected: visible to class and subclass w/i pkg

What's the equivalent of a dictionary in Java? Please create an example.

Map - Look in module about collections.

immutable

Means that once created, their values cannot be changed.

void

Means that the method does something but does not return any value at the end

9. A(n) -______- tells the computer to execute a method.

Method Call

19. A(n) -______- appears inside the parentheses of a method header, and contains a data type and a name.

Method Definition

hasMoreElements

Method of Enumeration. Tests if this enumeration contains more elements.

put

Method of Hashtable. Maps the specified key to the specified value in this hashtable.

remove

Method of Hashtable. Removes the key (and its corresponding value) from this hashtable.

containsKey

Method of Interface Map. Returns true if this map contains a mapping for the specified key.

start

Method of Thread. This method Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.

enumerate

Method of ThreadGroup. Copies into the specified array every active thread in this thread group.

run

Method. When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's this method to be called in that separately executing thread.

All objects in a class have the same _______ and same types of _______.

Methods && Instance Variables

13. A(n) -______- allows the application class to change the value stored in an instance variable.

Mutator Method

A no-argument constructor has....

No parameters.

if you call the next() method from the iterator interface and there are no more elements next() throws what exception?

NoSuchElementException

Reasons to use "int"

Numbers -2 billion to, 2 billion

Reasons to use "long"

Numbers greater then ±2 billion

4 Java Data Types?

Numeric, String, Character, Boolean.

*** If a variable is used as an argument...

ONLY the value of the the argument is plugged into the parameter, NOT the variable itself

10. An instance method must be called on a(n) -______- .

Object

Define the Java related "object" and what is it interchangeable with?

Object and class define state (data_ and behavior (operations). Classes define an object's behavior.

A class is a type whose values are ______

Objects

Private variable declaration?

Only applies to that class. ex. private String first;

public class{

Opens and names your program

Overriding vs Overloading

Overriding when return type, name, parameters the same. Overloading when name the same but parameters different. (overloading is illegal when extending a superclass)

A _____________ is like a blank in a method definition...

Parameter

What is assumed to be true when a method is called

Precondition

Method

Prewritten code to accomplish a task

7. The memory location that stores a value sent to a method is called a(n) -______-.

Primitive Variable

Layering Writer Classes

PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter(path)));

System.out.print(" ");

Prints a string of text

If an instance variable or method is _____ then it cannot be directly referenced anyplace except in the definition of a method of the same class.

Private

Default Class Constructor

Provided by java w/o arguments and invoked when there is no constructor

15. A(n) -______- stores the address of an object.

Reference Variable

12. A(n) -______- sends a value back to the caller.

Return Statement

return function?

Returns and expression. ex. return first + " " + middle + " " + last;

Syntax

Rules for combining words into sentences

Semantics

Rules for interpreting the meaning of statements

How to declare variables with the same data type on the same line?

Separate them with commas. ex. int number, salary, hoursWorked; (end with semi-colon)

Stream

Sequence of bytes that flow into or out of a program

Bit pattern

Series of 0's and 1's

Java vocabulary

Set of all words and symbols in the language

Method

Set of code that performs well-defined function

name [row] [col] = value

Set the value of an element

long totalMilliseconds = System.currentTimeMillis();

Sets total number of milliseconds since midnight, January 1, 1970, as a variable

Constructor

Special kind of method, build up an instance of a class

Object

Special kind of variable containing DATA and METHODS

Class Constructors

Special methods commonly used to initialize objects when they are created

things to do when refactoring (a class with redundancies)

SpecificClass whatever = new SpecificClass(); becomes a function SpecificClass whatever = createSpecificClass();

statement

Statements are roughly equivalent to sentences in natural languages. A statement forms a complete unit of execution.

What non-numeric data type can have class operations preformed to it?

String

What word is always capitalized in java syntax?

String

0 or more characters surrounded by double quotes?

String (always capital "S")

Example of variable declaration and explanation.

String firstName; Start with data type then variable name. Must end with the ";".

Example of how to retrieve the last string added to the vector:

String s = (String)v.lastElement();

Example of how to "get" a vector element using an index:

String s1 = (String)v.get(0); ( you must cast the returned element bc by default vectors are designed to work with the Object class

How could you define a String variable named wrd and initialize it to the word cats?

String wrd = "cats";

Multidimensional arrays

String[][] names = { {"Mr. ", "Mrs. ", "Ms. "}, {"Smith", "Jones"} };

Set of print commands to print to the console on two different lines?

System.out.print("Hello"); //no "ln" System.out.print("World"); //Has the "ln"

print the ARRAY moreNames

System.out.print(Arrays.toString(moreNames)); toString must be a static method...

Print to screen

System.out.println("Hello World!");

Command to print to the console? (what letter is capitalized)

System.out.println("Hello");

What System.out method moves the cursor to the next line?

System.out.println()

Given: String firstName = "reynald"; Writhe the line of code to out the index of letter 'a'

System.out.println(firstName.indexOf('e')); v23

Create a generic class as in v58

TODO

Create a generic method as in v59 and use bounded types (v60)

TODO

Create an example of Polymorphism that reflect v51

TODO

Create an example of changing inheritance to composition by using interfaces. See exampled in v54.

TODO

Create an example of composition. Create a car class that HAS a gas tank. After the car runs 200miles, make it request to add gas.

TODO inspired by v49 (paper tray example)

Create an example of inheritance and using a constructor by writing a method that print the name passed into the constructor. In the super class, use the keyword 'protected'

TODO v48

Create an example using 'wild cards'

TODO v61

What is erasure?

TODO v62

Create an IllegalAurgumentException (with some error message) in a method & on the calling method, add a try / catch block to display your error.

TODO - video on Excepions -->Try / Catch

What is a 'Queue' in Java?

TODO: Create a queue

What does empty Parenthesis at the end of a method declaration mean?

That the data for the method will be put in later.

Copying Arrays

The System class has an arraycopy method that you can use to efficiently copy data from one array into another: public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) The two Object arguments specify the array to copy from and the array to copy to. The three int arguments specify the starting position in the source array, the starting position in the destination array, and the number of array elements to copy.

boolean

The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined.

byte

The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.

char

The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).

Source code:

The combination of the import statements and the program statements

Class

The data type of an object

double

The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency.

float

The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification. As with the recommendations for byte and short, use a float (instead of double) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the java.math.BigDecimal class instead. Numbers and Strings covers BigDecimal and other useful classes provided by the Java platform.

Polymorphism

The idea that we can refer to objects of different but related types in the same way.

long

The long data type is a 64-bit two's complement integer. The signed long has a minimum value of -263 and a maximum value of 263-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1. Use this data type when you need a range of values wider than those provided by int. The Long class also contains methods like compareUnsigned, divideUnsigned etc to support arithmetic operations for unsigned long.

Operator Precedence

The rules that govern the order in which operations are done.

short

The short data type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with byte, the same guidelines apply: you can use a short to save memory in large arrays, in situations where the memory savings actually matters.

Token:

The smallest individual unit of a program written in any programming language.

Boolean Literal

The words true and false.

Threads

These share the process's resources, including memory and open files. This makes for efficient, but potentially problematic, communication.

Error

This Class indicates issues that an application should not try to catch. Subclass of the class Throwable.

Vector

This class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. However, the size of a this can grow or shrink as needed to accommodate adding and removing items after the this has been created.

Exception

This class indicates issues that an application may want to catch. A subclass of the class Throwable.

Object

This class is the root of the class hierarchy. Every class has this as a superclass. All objects, including arrays, implement the methods of this class.

Hashtable

This class maps keys to values. Any non-null object can be used as a key or as a value. To successfully store and retrieve objects, the objects used as keys must implement the hashCode method and the equals method.

ThreadGroup

This class represents a set of threads.

Context

This interface consists of a set of name-to-object bindings. It contains methods for examining and updating these bindings.

Enumeration

This interface generates a series of elements, one at a time. Successive calls to the nextElement method return successive elements of the series.

Runnable

This interface should be implemented by any class whose instances are intended to be executed by a thread. The class must define a method of no arguments called run.

writeObject

This method is used to write an object to the stream. Any object, including Strings and arrays, is written with this method. Multiple objects or primitives can be written to the stream. The objects must be read back from the corresponding ObjectInputstream with the same types and in the same order as they were written.

notifyAll

This method wakes up ALL waiting threads; the scheduler decides which one will run

notify

This method wakes up a single thread which is waiting on the object's lock

javax.swing.*;

To create lightwieght components for a GUI.

java.net.*;

To develop a networking application.

java.awt.*;

To paint basic graphics and images.

java.io.*;

To utilize data streams.

java.lang.*;

To utilize the core java classes and interfaces.

java.util.*;

To work with collections framework, event model, and date/time facilities.

T or F: The name of a local variable can be reused outside of the method in which it is declared ?

True

True or false, BitSets automatically grow ti represent the number of bits required by a program?

True?

Buffered Streams

Use a large block of memory to store batches of data that flow into or out of a program

When using primitive types with ArrayList

Use class Integer

Cast operator:

Used for explicit type conversion

Boolean type (boolean)

Used in conditional tests to control execution flow- TRUE or FALSE

//

Used to comment out a line.

/* */

Used to comment out a paragraph or longer

double

Used to declare and initialize a fraction interager. Ex: double canVolume = 0.335;

int

Used to declare and initialize a non fraction interager Ex: int canVolume = 5;

byte

Used to define a primitive variable as an integer with 1 byte of storage. Also a corresponding wrapper class.

==

Used to equal a value

Method Overloading

Using methods with the same name but different # and types of arguments

Object

Value of a class type. Stores its state in fields and exposes its behavior through methods

Constant

Variable whose value cannot be changed once initialized (final)

Class Variables

Variables associated with ENTIRE class

Instance Variables

Variables associated with each object from a class - stored in separate mem location

similar to a traditional Java array, except that it can grow as necessary to accommodate new elements and also shrink.

Vector

Example of a vector that has an initial size of 25 and expands in increments of 5 elements when more than 25 elements are added to it:

Vector v = new Vector(25, 5);

A class in the Java API

What is an ArrayList?

Java libraries

What is the Java API?

Post Condition?

What will be true after a method is called

Void

When a method does not return a value.

Implicit type coercion:

When a value of one data type is automatically changed to another data type.

Encapsulation

When each object protects its own information.

Reserved words

Words that have predefined meanings that cannot be changed

What escape sequence makes one backslash character in a print or println statement?

\\

What escape sequence makes the backspace character?

\b

What escape sequence makes the newline character?

\n

What escape sequence makes the tab character?

\t

bit

a binary digit that is the smallest unit of information. 1 or 0.

truth table

a breakdown of logic functions by listing all possible values

true

a class that has even one abstract method must be marked as an abstract class

System

a class that holds objects/methods to perform system-level operations, like output

What does /* suggest

a comment

Hash code

a computed key that uniquely identifies each element in a hash table.

array

a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created.

load factor

a floating-point number between 0.0 and 1.0 that determines how and when the hash table allocates space for more elements.~258PDF

Coordinate system

a grid that allows a programmer to specify positions of points in a plane or of pixels on a computer screen

method

a group of one or more programming statemetnts that collectively has a name

Package

a group of related classes in a named directory

A local variable disappears when...

a method invocation ends.

print

a method that prints characters to the screen and remains on the same line

class

a programmer defined data type. Blueprint from which individual objects are created. A class definition defines instance and class variable and methods. also specifies interfaces

Arithmetic expressions

a sequence of operands and operators that computes a value

Class

a set of instructions that create an object

Debugging

a step by step method of testing a program and correcting programming errors

control unit

a subsystem of the processor that can 1. fetch next instructions 2. decode them 3. execute them

algorithm

a well ordered collection of unambiguous and effectively computable operations that when executed produces a result and halts in a finite amount of time

method types allowed in abstract class

abstract (no body), or non-abstract...whereas interface defines ONLY abstract methods

Constructor Definition

accessSpecifier ClassName(parameterType paramterName, ...) { constuctor body }

Instance Field Declaration

accessSpecifier class ClassName { accessSpecifer fieldType fieldName; }

Class Definition

accessSpecifier class ClassName { constructors methods fields }

Method Definition

accessSpecifier returnType methodName(parameterType parameterName, . . .) { method body }

way to get private variables from another class

accessor methods

add() remove()

add something to ArrayList remove something to ArrayList

Write an expression that returns the position of the 1st occurrence of the String "Avenue" in address (a String).

address.indexOf("Avenue")

Type casting

allows one data type to be explicitly converted to another

Iteration construct/Loops

allows program to repeatedly execute instructions

concatenation operator

allows strings to be combined in Java

do(loop)

always execute once and keep executing while condition is true

ASCII

american standard code for information interchange. an international standard for representing textual info. 8 bits/character. allows a total of 256 character to be represented

Exception

an abnormal state or error that occurs during runtime and is signaled by the operating system

argument

an actual parameter in a method call or one of the values combined by an operator

Logic error

an error such that a program runs, but unexpected results are produced. Also referred to as a design error

What is an object in Java

an instance of a class

'this' refers to

an instance of the class. thus, 'this' cannot refer to static methods, which

parameter

an item of info specific to a method when the method is called

instance

an object of a particular class. Created using the new operator followed by the class name

out

an object that provides a way to send output to the screen

Create an array

anArray = new int[10];

Get the length of an array

anArray.length

Initialize an array

anArray[0] = 100; or int[] anArray = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };

numeric data types

another name for primitive data types; most commonly int and double

Boolean expression

any expression that evaluates to true or false

instance variable

any item of data that's associated with a particular object.

white space

any sequence of only space, tab, and newline characters

String concatenation

append a string or value to another string

ALU

arithmetic/logic unit. sub system that performs math and logical operations.

Array Element Access

arrayReference[index]

Arithemetic overflow

assigning a value to a variable that is outside of the ranges of values that the data type can represent

initialize

assigning a value to a variable when it's created

b

b

\\

backslash; causes a backslash to be printed

binary

base 2 positional numbering system composed of 1s and 0s

b

bb

Block

between two curly braces

Binary Seach

binarySearch(array, lowerboundIndex, upperboundIndex, key) public static void binarySearch(int[ ] array, int lowerbound, int upperbound, int key) { int position; position = ( lowerbound + upperbound) / 2; while((array[position] != key) && (lowerbound <= upperbound)) { comparisonCount++; if (array[position] > key) // If the number is > key, .. { // decrease position by one. upperbound = position - 1; } else { lowerbound = position + 1; // Else, increase position by one. } position = (lowerbound + upperbound) / 2;

constructor

block statement created when an object is declared

True False data type

boolean

Bubble Sort

boolean flag = true; int n []; for (int i = 0; i < n.length; i++) { if(!flag) break; flag = false; for(int j = 0; j < n.length - i; j++) { if(numLis[n] > numList[i+1] { int temp = numList[i]; numList[i] = numList[i++]; flag = true; } }

Example of how to use the contains method when working with hashtables:

boolean isThere = hash.contains(new Rectangle(0, 0, 5, 5));

Example of how to get the value of a individual bit in a set:

boolean isWriteable = connex.get(ChannelAttributes.WRITABLE);

Object oriented programming

building programs by creating, controlling, and modifying one or more objects

print vs println

carriage return

The next() method always returns an object of the class Object.To get around this you can _____ the object into a more appropriate object.~223

cast

how to set up try catch for exceptions

catch most specific first catch (FileNotFoundException e) {System.out.println("file not found"} catch (IOException e) {...} catch (Exception e) {...}

/b

causes the cursor to back up, or move left, one position

Alphabetic characters that can be stored as a numeric value?

char

Braces

characters used to mark the beginning and end of blocks of code

final keyword

code cannot be changed(overridden) by subclass

ArrayList<string> stringList = new ArrayList<string>();

code to declare a string array list called stringList

public class Triangle extends Shape

code to make triangle subclass from Shape superclass

Method returning an integer greater than, equal to, or less than 0 to indicate whether this string is greater than, equal to, or less than s1.

compareTo(s1) - it compares character by char. until difference in string letters found. - Then → returns an integer representing the difference in characters

Software

computer instructions or data. Anything that can be stored electronically

arithmetic expression

consists of operands and operators combined in a manner familiar from algebra

instantiation

construction of an object of that class

method, which simply checks whether an element is in the vector:

contains() (example:boolean isThere = v.contains("Webb");] )

continue vs break in a while loop

continue jumps back up to while, break jumps down out of while loop.

cast

converting a value from one type to another explicitly

Procedural programming

creating a program by using a step by step process to perform specific tasks

Variable declaration statement

declares the identifier and data type for a variable

semantics

define the rules for interpreting the meaning of statements

Semantic rules:

determine the meaning of instructions in a programming language.

Syntax rules:

determine the validity of instructions in a programming language.

For numeric data types what declaration will always be used?

double

How could you define a real number named numero and initialize it to 867.5?

double numero = 867.5

Insert a comment? On multiple lines?

double slash ex. //commented slash asterisk ex. /* one line two lines */ (its the back slash for both)

//

double slash; marks the beginning of a comment (a statement ignored by the computer)

how to give location of error

e.printStackTrace();

Random Access Memory

electronic circuits in a computer that can store code and data of running programs

==

equal to

Your classes should generally have both an _______ method and a _____ method.

equals && toString

Method returning true if this string is = to string 2

equals(s1)

\\

escape character for backslash

static variables

essentially global variables...when a member is declared static it can be accessed before any instance of its class is created and without reference to any object....static variables can be shared by multiple classes, but changing the static variable in one place changes it globally.

class Object

every class in Java is either a direct or indirect subclass of what?

import java.util import javax.swing

example java api package imports

Comments

explanatory sentences inserted in a program in such a manner that the compiler ignores them

actual parameters

expression supplied by a formal parameter of a method by the caller. Value of the parameter.

Mixed-mode arithmetic

expressions imvolving integers and floating-point values

implement an abstract class

extends public class Vehicle extends Crashable implements Drivable {}

CallableStatement

extends PreparedStatement. The interface used to execute SQL stored procedures. The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters can be used for input, output or both. Parameters are referred to sequentially, by number, with the first parameter being 1.

Members

fields(data the class holds), methods

Constant definition

final typeName variableName = expression;

indexOf() size()

find out where something is in ArrayList get number of elements in ArrayList

primitive data types

first category of Java variables such as numbers, characters, and Booleans

a Boolean value that represents one of a group of on/off type states in a program.

flag

FLOPS

floating point operations per second. measure of computer's performance at brute force applications

Example of how to loop through a entire vector using the iterator class :

for (Iterator i = v.iterator(); i.hasNext(); ) { String name = (String) i.next(); System.out.println(name); }

The "for each" loop

for (Type variable: collection) statement;

The for Statement

for (initialization; condition; update) statement;

"for loop" syntax

for (iterator initialization; iterator comparison; iterator incrementalization) {}

adjective name

for interfaces (modify a class, which is usually a noun) eg, public interface Drivable{}

Pass by value

for primitive data types

memory

function unit of a computer that stores and retrieves instructions and data

Accessors

get() methods

Naming standard for accessor method?

getABC();

Arguments

give method more info about what to do

Applets

graphics in java

what is overloading a method

having two methods with same name...the key is the methods must have different parameters

encapsulation

hiding of implementation details

Memory Data Register

holds the information to be transferred/copy of information received

/t

horizontal tab; causes the curson to skip over to the next tab stop

packages

how are classes grouped in java?

super.method();

how to call a superclass method in a subclass

how to do: if (x != false) {}

if (!(false)) this will run fortunately. however if (l

The if Statement

if (condition) statement; else statement;

String variables name1 & name2 Write a fragment of code assigning the larger of the 2 to the variable first (NOTE: "larger" here means alphabetically larger, not "longer". Thus, "mouse" is larger than "elephant" bc "Mouse" comes later in the dictionary than "elephant"!)

if (name1.compareTo(name2) > 0 ) { first = name1; } else { first = name2; }

Hashable class

implements Dictionary, an abstract class that defines a data structure for mapping keys to values. This is useful when you want to access data through a particular key rather than an integer index.

Stack class

implements a last-in, first-out stack of elements. You can think of a stack literally as a vertical stack of objects; when you add a new element, it's stacked on top of the others. When you pull an element off the stack, it comes off the top. That element is removed from the stack completely, unlike a structure such as an array, where the elements are always available.

Scanner

import java.util.Scanner static Scanner userInput = new Scanner(System.in); public static void main() { ... if (userInput.hasNextInt()) {} }

Basic Calculator

import java.util.Scanner; public class BuildingABasicCalculator7 { public static void main(String[] args) { Scanner bucky = new Scanner(System.in); double fnum, snum, answer; System.out.println("Enter first num "); fnum = bucky.nextDouble(); System.out.println("\nEnter second num "); snum = bucky.nextDouble(); answer = fnum + snum; System.out.println("\nFnum and Snum added together equal"); System.out.println(answer); } }

User Input

import java.util.Scanner; public class GettingUserInput6 { public static void main(String args[]){ Scanner bucky = new Scanner(System.in); System.out.println(bucky.nextLine()); } }

Methods With Parameters- Class 1

import java.util.Scanner; public class UseMethodsWithParameters15 { public static void main(String[] args) { Scanner input = new Scanner(System.in); UseMethodsWithParameters15P2 UseMethodsWithParameters15P2Object = new UseMethodsWithParameters15P2(); System.out.println("Enter your name here: "); String name = input.nextLine(); UseMethodsWithParameters15P2Object.simpleMessage(name); } }

Importing a Class from a Package

import packageName.ClassName;

how to get error message

in catch statement catch(ArithmeticException e) {e.toString());} which gives the exception name + the description, while getMessage() only gives description

Graphics context

in java, an object associated with a component where the images for that component are drawn

method, which finds the index of an element based on the element itself:

indexOf("Inkster"); (example: int i = v.indexOf("Inkster"); )

\n

indicates a newline character

\t

indicates a tab character

pseudocode

informal programming language with english like constructs

variables declared inside a class but outside any method

instance variables

Statements

instructions or commands within a method that make a program work

machine language

instructions that can be executed directly by the CPU

How could you define an integer named num and initialize it to 394?

int num = 394;

Example of how to find out how many buts are being represented in a set:

int numBits = connex.size();

1. Define a variable that = to ten. 2. Create a while loop that prints you name tens time.

int ten = 10; while(copies > ten) { System.out.println("Reynald"); copies --; }

conditional operator

int var = expression ? value 1 : value 2; (true/false) (true) (false)

Name the 6 numeric data types

int, double, short, long, byte, and float

Numeric Data Sub-Types

int, long, float, double

Declare an array

int[] anArray;

1. Create an Array called 'number' w/ 3 slots 2. Write out the 2nd number

int[] numbers = new int[3];

IDE

integrated development environment. a programming environment that includes an editor, compiler, and debugger

public and abstract

interface methods are implicitly what?

Iterator

interface that provides a standard means of going through a list of elements in a defined sequence, which is a common task for many data structures.

Serialize

involves saving the current state of an object to a stream, and restoring an equivalent object from that stream. The stream functions as a container for the object.

literals

items in programs whose values do not change; restricted to the primitive data types and strings

Literals

items whose values do not change, like the number 5.0 or the string "Java"

reason for abstract classes in java

java does not allow multiple subclasses

more eagle-eyed view of exception types

java.util.RunTimeException (developer responsible for catching these) java.util.Exception (compiler will warn about these errors anyway) common Exceptions, which are the 5 above types

Return

keyword that stops execution of the method,goes back to where you started

What could a object be compared to for similarity?

like base blocks that are interchangeable in how they can be used in other programs.

statements

lines of code in java

variables declared inside a method or method parameter

local variables

Number of comparisons in binary search

log(n)

boolean operator

logical operator. && || !=

Infinite loop

loop that goes forever(while)

4. The -______- is where the program begins execution.

main Method

Helper methods should be

marked as private

hasNext()

method determines whether the structure contains any more elements.(if you've implemented the iterator interface)

contains()

method from hashtable class that checks whether an object is stored in the hash table.

public static void main(String [ ] args)

method header;

clone

method of Object. Creates and returns a copy of this object( Class Object).

next()

method retrieves the next element in a structure. (if you've implemented the iterator interface)

mutator method

method that changes the state of an object

Mutator methods

methods that change the values of the field

The two main kinds of methods:

methods that return a value / void methods

ArrayList methods

names.size() names.get(i); names.set(0, "Felicia Day"); this will REPLACE John Smith names.remove(3); copy: copiedAR.addAll(names); copy names ArrayList into copiedAR if (names.contains(paulYoung)) {} to check if two arrays are equal (containsAll elements of ) -- if (names.containAll(namesCopy)) {} //if the ArrayList names contains All elements in namesCopy .clear() .isEmpty() secondCopy = namesCopy.toArray(); //copy to secondCopy

<0

negative

Array Construction

new tymeName[length];

instantiation operator

new, third highest precedence, right to left association

/n

newline; advances the curson to the next line for subsequent printing

how is constructor definition different from a method

no return type...constructor includes access modifier, which is usually public, but can also (surprisingly) be private or default(no access modifier at all (?))

is private variable accessible within inherited subclass

no...access violation...and reason for accessor methods

Comments

nonexecutable statements in a program that can be used to document the purpose of the program or to track changes to the program

!=

not equal

!

not(makes true or false)

Primitive data types

numbers, characters, and Booleans. combined in expression with operators

Method call

object.methodName(parameters);

When using the BitSet class "0" represents ______

off or false(boolean)

When using the BitSet class "1" represents ______

on or true(boolean)

Method

one or more statements in a class performing a specific task within an object

/** */

opening comments

{ }

opening/closing braces; encloses a group of statements, such as the contents of a class or a method

( )

opening/closing parentheses; used in a method header

||

or(one or both are true)

explicit parameter

parameter of a method OTHER THAN THE OBJECT ON WHICH METHOD IS INVOKED

logic gate

performs a logical operation on one or more logic inputs and produces a single logic output

Decision Construct

permits program to make logical decisions and choose between alternate execution paths

>0

positive

System.out.println( _____ );

prints the content in the parentheses ( _____ ) and moves to the next line

System.out.print( _____ );

prints the content in the parentheses ( _____) and remains on the same line

private accessor: security vs freedom

private often cited as giving SECURITY...but most often, it gives freedom to change instance fields

class and package access modifiers

public - member accessible within and outside package private - member accessible only to other members within class (NOT subclass!) protected - accessible within package and all of its subclasses (including subclasses in other packages)

default access modifier, type for variables within interfaces

public abstract

How to define a class?

public class "class name" (no extension)

If Statement

public class IfStatement10 { public static void main(String[] args) { int test = 6; if (test == 9){ System.out.print("yes"); }else{ System.out.println("this is else"); } } }

Increment Operator

public class IncrementOperators9 { public static void main(String[] args) { int tuna = 5; int bass = 18; ++tuna; System.out.println("Tuna- " + tuna); System.out.println("Bass- " + bass++); int x; x = 5; x += 5; System.out.println("this is x- " + x); int y; y = 2; y *= 5; System.out.println("this is y- " + y); } }

Logical Operator

public class LogicalOperators11 { public static void main(String[] args) { int boy, girl; boy = 18; girl = 68; // && both have to be true, || one has to be true if (boy > 10 && girl < 60){ System.out.println("You can enter"); }else{ System.out.println("You can not enter"); } } }

Math Operators

public class MathOperators8 { public static void main(String[] args) { int girls,boys,people; girls = 11; boys = 3; people = girls % boys; System.out.println(people); } }

Switch Statement

public class SwitchStatement12 { public static void main(String[] args) { int age; age = 30; switch (age){ case 1: System.out.println("you can crawl"); break; case 2: System.out.println("you can talk"); break; case 3: System.out.println("you can get in trouble"); break; default: System.out.println("I dont know how old you are"); break; } } }

Methods With Parameters- Class 2

public class UseMethodsWithParameters15P2 { public void simpleMessage(String name) { System.out.println("Hello " + name); } }

Multiple Classes- Class 1

public class UsingMultipleClasses14 { public static void main(String[] args) { UsingMultipleClasses14Part2 MultipleClasses2Object = new UsingMultipleClasses14Part2(); MultipleClasses2Object.simpleMessage(); } }

Multiple Classes- Class 2

public class UsingMultipleClasses14Part2 { public void simpleMessage(){ System.out.println("This is another class"); } }

Variables

public class Variables5 { public static void main(String args[]){ double tuna; tuna = 5.28; System.out.print("I want "); System.out.print(tuna); System.out.println(" movies"); } }

define new class Vehicle that implements Drivable interface

public class Vehicle implements Drivable

While Loop

public class WhileLoop13 { public static void main(String[] args) { int counter = 0; while (counter < 10){ System.out.println(counter); counter++; } } }

use of throws

public static void getAFile(String filename) throws IOException, FileNotFoundException{ FileInputStream file = new FileInputStream(filename); } and above in the main method, will set up try/catch blocks for suspect code

the entry point for your application

public static void main(String [] args)

Standard Starting, to start code block?

public static void main(String[] args) { //code goes here }

Given this method below, implements 'continue' or 'break' statement if color is 'green' public void printColors() { String[] colors = new String[] {"red","blue", "green","yellow"}; for (String c : colors) { System.out.println(c); } }

public void printColors() { String[] colors = new String[] {"red","blue", "green","yellow"}; for (String c : colors) { if("green".equals(c)) continue; System.out.println(c); } }

" "

quotation marks; encloses a string of characters, such as a message that is to be printed on the screen

IS-A relationship

relationship to describe extends

HAS-A relationship

relationship to describe instance variables

removes an element based on the element itself rather than on an index:

removeElement("Inkster");

console.nextDouble():

retrieves that floating-point number, if the value of this expression is that floating-point number.

The return Statement

return expression;

/r

return; causes the cursor to go to the beginning of the current line, not the next line

syntax

rules that define how to form instructions in a particular programming language

objects

second category of Java variables such as scanners and strings

;

semicolon; marks the end of a complete programming statement

Objects

sent messages

loop

sequence of instructions that is executed repeatedly

method

sequence of statements with a name. may have formal parameter and may return a value.

instruction set

set of all operations that can be executed by a processor

Mutators

set() methods

What is the method signature of public void setDate(int month, int day);?

setDate(int, int);

Naming standard for mutator method?

setXYZ();

programming vs natural languages

size, rigidity, literalness

I/O buffer

small amount of memory inside the I/O controller

I/O controller

special purpose computer that handles details of input and output and compensates for speed difference between I/O devices and other parts of the computer.

Parameter passing

specifying expressions to be actual parameter values for a method when it is called

Class/Static Method

static keyword

mass storage

storage of large amount of data in machine readable form for access by a computer system

computer science

study of algorithms including their: mathematical and formal properties, hardware realizations, linguistic realizations, and application

subclass extends the superclass

superclass / subclass relationship in java

int x = (int)a;

syntax to cast type (double a = 1.54;) into an int

public Class Dog extends Animal implements Pet{}

syntax to create an Animal subclass called dog that has a pet interface

super.runReport();

syntax to run superclass' runReport() method

Loop

tells java do things over and over

Cache Memory

temporary storage area where frequently accessed data can be stored for rapid access. fast, expensive, small. First site of search.

if-else construct

tests value of var/expr

The capacity of a vector is:

the amount of memory allocated to hold elements, and it is always greater than or equal to the size.

Uppercase

the capital letters of the alphabet

Stored Program concept

the computers ability to store program instructions as binary in main memory for execution. Created by von Neumann

Object

the instance of a class containing data and the functions that manipulate the data

address

the memory address of the values of which an operation will work

Lowercase

the non capital letters of the alphabet

The size of a vector is:

the number of elements currently stored in it.

implicit parameter

the object on which a method is invoked. comes before the method. myAccount.getDeposit(). my account is the implicit parameter

Scope

the part of a program in which the variable is defined

Origin

the point (0,0) in a coordinate system

Main method

the primary method in a java application program

syntax

the rules for combining words into sentences

vocabulary

the set of all of the words and symbols in a given language

literal

the source code representation of a fixed value

A parameter is a local variable initialized to....

the value of the corresponding argument. (Known as Call-by-value)

von neumann architecture

theoretic model of computer design that structures the origin of all modern computers. four subsystems: memory, in/output, ALU, control unit.

What is the biggest limitation to using arrays?

they cant adjust in size to accommodate greater or fewer elements.

ObjectInputStream

this class deserializes primitive data and objects previously written using an ObjectOutputStream. ObjectOutputStream and this class can provide an application with persistent storage for graphs of objects when used with a FileOutputStream and FileInputStream respectively. this class is used to recover those objects previously serialized. Other uses include passing objects between hosts using a socket stream or for marshaling and unmarshaling arguments and parameters in a remote communication system.

using this(newHealth) within constructor

this goes up to the root class (Monster) and newHealth refers to it's field (class variable)

5. The -______- always returns a reference to a String that contains the state of the object.

toString Method

primitive data type

total of 8, include 4 integer types and 2 floating point types. int 4, byte 1, short 2, long 8, double 8, float 4, char 2, boolean 1 bit. A value that's not a reference to an object.

stack and heap

two main memory locations for Java

super keyword in Java

two uses 1) call a superclass constructor (since superclass/subclass constructors seem to be confusing business) 2) access a member of the superclass that has been hidden by a member of a subclass

Variable definition

typeName variableName = value;

how to prevent overriding or inheritance

use of final before class declaration

Escape character (\)

used in codes to represent characters that cannot be directly typed into a program

escape character

used when including 'special characters' in string literals

Array Manipulations

useful operations provided by methods in the java.util.Arrays class, are: Searching an array for a specific value to get the index at which it is placed (the binarySearch method). Comparing two arrays to determine if they are equal or not (the equals method). Filling an array to place a specific value at each index (the fill method). Sorting an array into ascending order. This can be done either sequentially, using the sort method, or concurrently, using the parallelSort method introduced in Java SE 8. Parallel sorting of large arrays on multiprocessor systems is faster than sequential array sorting.

BitSet class

useful when you need to represent a large amount of binary data, bit values that can be equal only to 0 or 1. These also are called on-or-off values

Example of how to add a element to a vector:

v.add("Inkster");

How would you wipe out all of a the elements inside of a vector named "v"

v.clear();

Example of how to remove items from a vector:

v.remove(3);

example of how to change a specific element :

v.set(1, "Kung");

formal parameter

variable in a method definition. initialized with an actual parameter when method is called.

final

variable is defined with the reserved word its value can never change. Ex: final double .canVolume = 0.335;

local variable

variable whose scope is a block

Assignment

variableName = value;

Constants

variables whose values cannot change

romantics

very invested in cult of genius...write about michalangelo....seems to be pront to depression...forgets to take off boots... modern notion of genius invested in notion of intellectual originality...copyright law

instance variables and methods

what are members of a class?

type name in angle brackets

what is a type parameter

when you don't want a class to be instantiated

what is an abstract class?

a reference variable of the object type linked together by the = operator

what is an object

changing an inherited method

what is overriding

package name + class name

what is the full class name

abstract and non-abstract

what kind of methods are allowed in an abstract class

default

what to do if not listed case

run-time errors

when a computer is asked to do something that is considered illegal

variable declaration statement

when a program declares the type of a variable

syntax errors

when a syntax rule is violated

scope

when a variable can be accessed in the same block

logic errors

when the computer is unable to express an answer accruately

When is the BitSet class useful?

when you need to keep up with a set of Boolean values; you simply assign a bit to each value and set or clear it as appropriate.

on the stack inside the frame corresponding to the method where the methods were declared

where do all local variables live?

The while Statement

while (condition) statement;

socrates daemon

whispered the language of the gods into his ear before he did something incorrect vessel genies harnessed by divine madness infused by the goes that whips the individual into ecstatic states and pushes them into writing great things aristotle infused before birth == the problems -- written by student -- why is it that individuals of great capacity seem to be subject to melancholy? sanguine? extradorinary indiviuals have similary physiology ...side effects...maddness...irrationality its sad to think of how many geniuses have died on the african veldt

setup a constructor

within Monster class, create public Monster(int newHealth, int newAttack, int newMovement) {}

local vs instance variables

within a method(so w/in method's stack frame) vs not...a constructor IS NOT a method... instance variables live on the heap and are best set as parameters to the constructor in a single call...thus constructing object and its variable (initializing object's state) in one call

keywords

words in java that cannot be used as user-defined symbols

import x.y.z

x - overall name of package, y - name of package subsection, z - name of particular class in subsection

What is this "x+=3" the equivalent of?

x = x + 3;

compound assignments

x+=1

difference between while loop and do while loop

x=10 do { System.out.println("X is equal to " +x); x++; } while (x<10) This will return "X is equal to 10", while while loop would not return any thing at all. (Do-while returns initialization, regardless of whether it meets while condition).

Block statement

{ statement; statement; }

What must every method and class have an open and closed of?

{ } (braces, or curly brackets)

Array

~An ordered set of values of the same time stored in CONTIGUOUS blocks of memory ~non-primitive

Array subscripts

~Anything that evaluates to integer value ~Begin with 0 ~Cannot be negative ~Should not be referenced beyond bounds

Scanner Class

~Scans input from various sources and returns representations of primitive types

String

~Set of characters that are treated as objects ~Are immutable

ArrayList

~Subclass of Collection ~Works like an array, but SIZE can be EXPANDED easily. Very efficient for random accessing, but not so for inserting in the middle.

Reading from Text Files

~Uses Reader class ~BufferedReader: Provides buffered text stream reading ~FileReader: Connects an input stream to file

Writing to Text Files

~Uses Writer class ~BufferedWriter: Writes text to text output streams and provides buffering ~PrintWriter: Uses methods to write formatted data to output streams ~FileWriter: connects an output stream to a file

ArrayList Methods

~add(object): adds to end of list ~add(index, object) ~set(index, object) - replaces ~get(index) ~remove(index) size() isEmpty() - boolean clear() - removes all elements

String Class Methods

~length() ~substring(starting pos(, ending pos)) ~toUpperCase(), toLowerCase() ~charAt() ~equals()

Scanner methods

~nextInt(),....,nextLine() ~next(): returns next token ~hasNext(): boolean: returns true if source is full; false if empty

PrintWriter Methods

~print(arg) ~println(arg)


Conjuntos de estudio relacionados

Age Discrimination in Employment Act

View Set

Module 14.1: Latin American Peoples Win Independence

View Set

Funds Basics MedSurg Infectious Disease and Respiratory

View Set

Ch 19: Postoperative Nursing Management

View Set

Module 3.3 Chapter 12. Achievement.

View Set