Show Menu
Cheatography

CSC 201 final Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Hello World

/ Noc_Luppus /
import java.u­til.Date;
public class Hello
 {
    public static void main(String[] args)
    {
       System.out.println("100  100 = 10,000 & 1000  100 = 100,000");
   }
 } // dont forget me

program develo­pment

program develo­pment = WHAT
software design = HOW & create the pseudocode with classes and objects needed
software implem­ent­ation = requires the least amount of creativity
goal of testing is to find logical and run-time errors

class/­method

public static void main(S­tring[ ] args)
A class constr­uctor usually defines how an object is initia­lized
A Java variable is the name of a data value stored in memory that can change its value but cannot change its type during the program's execution
it all so can contain a value or a reference
local variable's scope is restricted to the method where it was declared
Abstract methods are used when defining abstract classes & Interfaces
All classes in Java are directly or indirectly subclasses of the Object class
Autoboxing is the automatic creation of a wrapper object from its corres­ponding primitive type, it also provides a static constant
method overlo­ading = having multiple class methods of the same name where each method has a different number of or type of parameters
If two variables contain aliases of the same object thenthe object may be modified using either alias & the object will become an "­orp­han­" if both variables are set to null
Inheri­tance through an extended (derived) class supports code reuse
Instance data for a Java class may be primitive types or objects
Static methods cannot reference instance data
The advantages of the Decima­lFormat class compared with the Number­Format class include precise control over the number of digits to be displayed
The behavior of an object is defined by the object's methods
The relati­onship between a class and an object is best described as a objects are instances of classes
encaps­ula­tion, inheri­tance, polymo­rphism are the main progra­mming mechanisms that constitute object­-or­iented progra­mming
all clases can have any number of children but only one parent
compareTo is not a method of the Object class
 

JavaFX

A color image is broken down into individual pixels in RGB
In a develo­pment enviro­nment that fully supports JavaFX, Since the launch method is called automa­tic­ally, you do not need to write the main method, and the launch method is called automa­tically
upper-left corner of a stage is (0,0)
You should override the start method in a JavaFX Applic­ation
Parent, Group, StackPane can be used as a root node in a JavaFX, ImageView cannot
the javafx.sc­ene.shape package includes classes that represent shapes in JavaFX
windowsis not a kind of object that is used to create a graphical user interface in JavaFX

array

in Java, arrays are objects
int[ ] arr = new int[n];
    arr.length = n
    Index = 0 - n-1
If a and b are both int arrays, then a = b; will create an alias
an int array is passed as a parameter to a method you would say: (int[ ] a)
if the statement arr[-1] = 0, it will thrown the ArrayI­nde­xOu­tOf­Bou­nds­Exc­eption Exceptions
The "off-by-one" error associated with arrays arises because the first array index is 0 or the loop went to far
str.ch­arA­t(2); could throw a String­Ind­exO­utO­fBo­und­sEx­ception becaus teh arry could be smaller than 3
Their lengths never change & The shortest string has zero length these are properties are true of String objects

sorting algorithms

Neither method requires additional memory betwwen selection sort and insertion sort
We compare sorting algorithms by examining the number of instru­ctions executed by the sorting algorithm
the efficiency of binary search is O(log2 n)
enum Speed { FAST, MEDIUM, SLOW }; zero = FAST

exspetoins

A finally clause will execute in any circum­stance
An exception can produce a "call stack trace" which lists: the active methods in the opposite order that they were invoked
NullPo­int­erE­xce­ption and Arithm­eti­cEx­ception are both derived from the Runtim­eEx­ception class
unchecked exception requires no throws clause
checked exception requires a throws clause
When a program terminates because a thrown exception is not handled, the program outputs a message indicating what and where the exception was thrown
String­Ind­exO­utO­fBo­und­sEx­ception is for a string or arry trys to get a vule outside of the index of the object
this is NOT a way: throw the exception to a pre-de­fined Exception class to be handled
 

UML

In a UML diagram for a class & there may be a section containing the attributes (data) of the class & there may be a section containing the name of the class & classes are repres­ented as rectangles

DEFF

instan­tiation
creating a new object of the class
Polymo­rphism
is achieved by overriding
flow of control
The idea that program instru­ctions execute in order (linearly) unless otherwise specified
actual parameters
The expres­sions that are passed to a method in an invocation
exception propag­ation
is The list of methods is known as the call stack and the method of searching them
call stack
0-9,$,­-,a-Z
allowed in an identifier
(,{,[ --- (< does not)
needs an associated "­clo­sin­g" character
syntax
gramer
semantics
comper­hentoin
base class is a parent class or super class
child
this
An object that refers to part of itself within its own methods can use this reserved word
super
An object that access a parent class' constr­uct­or(s) , methods and instance data can use this reserved word
new
reserved words in Java is used to create an instance of a class

LOOPS

The break statement transfers control out of the current control structure such as a switch statement
the do loop will always execute the body of the loop at least once, thewhile dose not
all three loop statements are functi­onally equivalent
while loops and do loops are essent­ially the same; but while loops always execute at least once
& if you know the number of times that a loop is to be performed, the best loop statement to use is a while loop
& loops may be replaced by an approp­riate combin­ation of if-else and switch statements

modifiers

public
everyone can see
private
only child can inderectly interact
protected
only child can see
static
static means it belongs to the class not an instance
abstract
are used when defining: abstract classes, derived classes
finsl
cannot be changed