\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{NoxLupus (NoxLupus)} \pdfinfo{ /Title (csc201.pdf) /Creator (Cheatography) /Author (NoxLupus (NoxLupus)) /Subject (CSC201 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{75751D} \definecolor{LightBackground}{HTML}{F6F6F0} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{CSC201 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{NoxLupus (NoxLupus)} via \textcolor{DarkBackground}{\uline{cheatography.com/46432/cs/14862/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}NoxLupus (NoxLupus) \\ \uline{cheatography.com/noxlupus} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 15th April, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Hello World}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{/* Noc\_Luppus */ \newline import java.util.Date; \newline public class Hello \newline \{ \newline ~~~ public static void main(String{[}{]} args) \newline ~~~ \{ \newline ~~~~~~ System.out.println("100 * 100 = 10,000 \& 1000 * 100 = 100,000"); \newline ~~~\} \newline \} // dont forget me} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.00248 cm} p{0.4177 cm} x{2.33912 cm} p{0.4177 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Data Types}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Primitive} types & size & Reference types & size \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} byte & 8 & Byte & \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} short & 16 & Short & \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} int & 32 & Intager & \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} long & 64 & Long & \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} float & 32 & Float & \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} double & 64 & Double & \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} char & 16 & Charter & \tn % Row Count 9 (+ 1) % Row 8 \SetRowColor{LightBackground} bool & 8 & Boolean & \tn % Row Count 10 (+ 1) % Row 9 \SetRowColor{white} & & All classes are reference type like:\{\{nl\}\}Scanner, Random, Die, int{[}{]}, String{[}{]} & \tn % Row Count 14 (+ 4) % Row 10 \SetRowColor{LightBackground} holds value & & holds a \{\{nl\}\}{\bf{pointer}} to a value & \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{5.377cm}}{•{\emph{ Term primitive is used with several meanings: }} \newline • Provided as part of language \newline • Not composite (ie no component parts) \newline • Variable stores value \newline • Variable is not a pointer to the value \newline • Autoboxing is the automatic creation of a wrapper object from its corresponding primitive type} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{data convertoin}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/noxlupus_1519423076_csc data.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{• Solid lines lose no information \newline • Dotted lines may lose precision (but not magnitude) \newline • Chars are unsigned 16 bit values, shorts are signed 16 bit values \newline • A narrowing conversion of a value of an integer type simply truncates the value} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{DecimalFormat}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The advantages of the DecimalFormat class compared with the NumberFormat class include precise control over the number of digits to be displayed} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Java.text's NumberFormat dose not truncate their display during the formatting process} \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`DecimalFormat fmt=new \seqsplit{DecimalFormat("0.\#\#\#\#\#\#);`}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{strings}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{String objects' lengths never chang and the shortest string has zero length \newline % Row Count 2 (+ 2) • Strings: have a .length() method (vs args.length field) \newline % Row Count 4 (+ 2) • Strings are dynamic and immutable \newline % Row Count 5 (+ 1) ~~~• Each version of s is newly allocated \newline % Row Count 7 (+ 2) ~~~• Mutable strings do exist \newline % Row Count 8 (+ 1) • Strings are not arrays of characters \newline % Row Count 9 (+ 1) ~~~• Although a String does contain an array of characters% Row Count 11 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Class Math}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{•Clients of Math can access its members using the class rather than objects \newline % Row Count 2 (+ 2) •Static members can be accessed using either the class or an object \newline % Row Count 4 (+ 2) •sqrt and PI are declared as static% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{enumeration}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Consider the following enumeration\{\{nl\}\} `enum Speed \{ FAST, MEDIUM, SLOW \};`} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{`Speed.charAt(0)` = FAST\{\{nl\}\}`Speed.charAt(1)` = MEDIUM\{\{nl\}\} `Speed.charAt(2)` = SLOW} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{enumerations are like a sting of things, but they are unchangeable and, can be referenced by number} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{javafx comands}} \tn % Row 0 \SetRowColor{LightBackground} Rectangle name= new Rectangle(x, y, \textless{}\textgreater{}x, \textless{}\textgreater{}y); & rectangle upper-left corner is at coordinates (x, y) and its dimensions are \textless{}\textgreater{}x X \textless{}\textgreater{}y \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} Circle name= new Circle(x, y, r); & circle, centered at coordinates (x, y) and ridus of r \tn % Row Count 8 (+ 3) % Row 2 \SetRowColor{LightBackground} \seqsplit{name.setStrokeWidth(2);} & sets the size of the lines \tn % Row Count 10 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{name.setFill(Color.GREEN);} & fills the shape with a color \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{JavaFX Qs}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The individual items held within the JavaFX scene graph are known as nodes. root = first, branch = parent, leef = child} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Parent, group, and stackPane nodes can be used as a root node in a JavaFX} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The javafx.scene.shape packages includes classes that represent shapes in JavaFX} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Event, control, and event handler are a kind of object that is used to create a {\bf{g}}raphical {\bf{u}}ser {\bf{i}}nterface} \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{You should override the start method in a JavaFX Application} \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{In a development environment that fully supports JavaFX, Since the launch method is called automatically, you do not need to write the main method} \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{A color image is broken down into individual pixels (points), each of which is represented by RGB} \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{The coordinate of the upper-left corner of a stage is 0,0} \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.38896 cm} x{2.58804 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{arrays}} \tn % Row 0 \SetRowColor{LightBackground} DataType{[}{]} name = new DataType{[}x{]}; & crates a array, lanth x, DataType = int, string, char, object...ect, index = 0 - x-1 \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} {\bf{a}}(int arrays) = {\bf{b}}(int array); & will create an alias of b \tn % Row Count 7 (+ 2) % Row 2 \SetRowColor{LightBackground} "off-by-one" error & a loop gose +- too many times \tn % Row Count 9 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{ArrayIndexOutOfBoundsException} & when the input is out of bounds like: arr{[}-1{]} = 0; \tn % Row Count 12 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{an int array is passed as a parameter to a method, (int{[} {]} a) would adequately define the parameter list for the method header} \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{sorting algorithms}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{We compare sorting algorithms by examining the number of instructions} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{} \tn % Row Count 2 (+ 0) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{the amount of memory required by selection sort and insertion sort, neither method requires additional memory} \tn % Row Count 5 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{selection sort: O(n2) time complexity} \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{insertion sort: dose one item at a time. It is much less efficient on large} \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{binary search: O(log2 n) efficiency} \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{classes}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{• Everything in Java is declared inside a class \newline % Row Count 2 (+ 2) • Packages are collections of classes \newline % Row Count 3 (+ 1) • Multiple classes per file allowed. But only one public class per file \newline % Row Count 5 (+ 2) • If a file contains a public class, the file must have the same name as the public class \newline % Row Count 7 (+ 2) • Careful: What do we mean when we refer to the class Hello? \newline % Row Count 9 (+ 2) •~ Classes are the only structured or user-defined types \newline % Row Count 11 (+ 2) In addition to their usage providing a mechanism to convert (to box) primitive data into objects, the wrapper classes provide static constants \newline % Row Count 14 (+ 3) All classes must have 1 parent (other than the object class with has no parent) but may have any number of children (derived or extended) classes% Row Count 17 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The relationship between a class and an object is best described as objects are instances of classes witch is created by the reserved word {\bf{new}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Java Classes' Purposes}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{•Template for creating objects \newline % Row Count 1 (+ 1) •Type for (reference) variables \newline % Row Count 2 (+ 1) •Encapsulation mechanism (eg visibility control) \newline % Row Count 4 (+ 2) •Library of routines and constants% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Objects}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Objects serve two purposes: }} \newline % Row Count 1 (+ 1) 1. Objects model entities in real world (eg students, books) \newline % Row Count 3 (+ 2) 2. Objects are instances of abstract data types (eg stacks and queues) \newline % Row Count 5 (+ 2) {\bf{Objects typically described as having 3 characteristics: }} \newline % Row Count 7 (+ 2) 1. State: Data \newline % Row Count 8 (+ 1) 2. Behavior: Actions the object can take, perhaps modifying data \newline % Row Count 10 (+ 2) 3. Identity: Objects are distinct (even if data is the same) and can be distinguished \newline % Row Count 12 (+ 2) {\bf{Programming with objects involves }} \newline % Row Count 13 (+ 1) Creating objects \newline % Row Count 14 (+ 1) Sending them messages% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Consider modeling a library's books \newline 1. State: Author, title, status, ... \newline 2. Behavior: getTitle, hold, checkout, return \newline 3. Identity: Object of each book \newline Hmmm, multiple copies???} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Methods}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{• {\bf{Important rule:}} {\emph{Static methods can call static methods only}} \newline % Row Count 2 (+ 2) • {\bf{Instance methods}} are declared without keyword static \newline % Row Count 4 (+ 2) • {\bf{Private}} methods are not visible outside the class \newline % Row Count 6 (+ 2) • {\bf{Method}} declarations methods are declared inside classes, not other methods (i.e., no nested methods) \newline % Row Count 9 (+ 3) • Having multiple class methods of the same name but differing types or numbers of variables {\bf{method overloading}} \newline % Row Count 12 (+ 3) •{\bf{Static}} methods can not reference instance data \newline % Row Count 14 (+ 2) •methods define the object's behavior% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Abstract}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Abstract methods are used when defining: abstract classes, derived classes} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{variable}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{In Java a variable may contain a value or a reference not a class, method, or package} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{If two variables contain aliases of the same object, then: the object may be modified using either alias, the object will become an "orphan" if both variables are set to null} \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{a Java identifier can contain only A-Z, a-z, 0-9, \_ and \$, and start only with one of A-Z, a-z, or \$.} \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{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} \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Literals}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{(2 \textgreater{} 3) ? true : false; \newline "text".substring(2); \newline System.out.println("Display a hard coded float: " + 37.19f);} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{The code section 3.62 contains two number literals followed by two boolean literals at line 1, one string literal followed by one number literal at line 2, and one string literal followed by one real number literal at line 3:} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Instance Variables}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Variables length and width are called instance variables} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Each instance of the class gets a copy} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Instance Variables are also called fields} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Instance data for a Java class may be primitive types or objects} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Scope: Entire class (and beyond, if not private)} \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Declared inside class but not inside any method} \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Instance variables should always be declared private} \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`public class Box\{` \newline `int foo = 5;` \newline `int bar = 10;` ` \}` \newline {\bf{default values}} \newline integer type: 0 \newline floating point type: 0.0 \newline type boolean: false \newline type char: null character (\textbackslash{}u0000) \newline reference type: null \newline array references: null} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Program Development}} \tn % Row 0 \SetRowColor{LightBackground} establishing the requirements & {\bf{what}} \{\{nl\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} creating a design & {\bf{how}} \{\{nl\}\} determine the classes and objects needed \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} implementing the code & least creative step \{\{nl\}\} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} testing the implementation & goal: to find logical and run-time errors \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.2531 cm} x{2.0885 cm} p{0.4177 cm} p{0.4177 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{simbles}} \tn % Row 0 \SetRowColor{LightBackground} comments & . & & \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} // one line & method(args)\{\{nl\}\} sum(int1, int2)... & & \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} /* multi */ & ++\{\{nl\}\} adds one & & \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} /** javadoc */ & +\{\{nl\}\} adding & & \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} & / + \% \{\{nl\}\} divition + remainder & & \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} & \textasciicircum{}= |= \&= \textgreater{}\textgreater{} = \textgreater{}\textgreater{}\textgreater{}=\{\{nl\}\} & & \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Terms}} \tn % Row 0 \SetRowColor{LightBackground} Packages & are collections of classes \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} class & everthing is writen with in a class, blue print of object \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} object & an instance of a class \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} Method & main is a method (ie procedure or function) \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} Member & Methods are one of the kinds of members that can be in a class \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} Access modifier & specifies visibility \tn % Row Count 14 (+ 1) % Row 6 \SetRowColor{LightBackground} Kernighan and Ritchie (K \& R) style & stase nl.starts nl.code end \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} Allmann style & nl.stase nl.starts nl.code end \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} camel style & (eg doSomethingBig()) Variables, methods, packages \tn % Row Count 21 (+ 3) % Row 9 \SetRowColor{white} capitalized & (eg Hello) classes \tn % Row Count 22 (+ 1) % Row 10 \SetRowColor{LightBackground} all\_uppercase & CM\_PER\_INCH = 2.54; Constants \tn % Row Count 24 (+ 2) % Row 11 \SetRowColor{white} instantiation & means creating a new object of the class or a new alias of a object \tn % Row Count 28 (+ 4) % Row 12 \SetRowColor{LightBackground} alias & two different numeric variables refer to the same physical object \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Terms (cont)}} \tn % Row 13 \SetRowColor{LightBackground} API & Application Programming Interface \tn % Row Count 2 (+ 2) % Row 14 \SetRowColor{white} flow of control & the idea that code runsright though onless told other wise \tn % Row Count 5 (+ 3) % Row 15 \SetRowColor{LightBackground} arrays & are objects \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.29402 cm} x{3.68298 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Precedence}} \tn % Row 0 \SetRowColor{LightBackground} postfix & . {[} {]} method(args) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} unary & ++ -{}- + - new (type) \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{multiplicative} & * / \% \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} additive & + - \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} \seqsplit{assignment} & = += -= *= /= \%= \textasciicircum{}= \&= |= \textless{}\textless{}= \textgreater{}\textgreater{}= \textgreater{}\textgreater{}\textgreater{}= \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Constructors}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{• Constructor has same name as class \newline % Row Count 1 (+ 1) • No return type for constructors \newline % Row Count 2 (+ 1) •Possible to have method and constructor with same name! \newline % Row Count 4 (+ 2) • Default no parameter constructor provided if no other constructors are provided \newline % Row Count 6 (+ 2) • Default constructor is NOT provided if others are (which can cause problems in some circumstances ) \newline % Row Count 9 (+ 3) • Constructors override initializations in declarations% Row Count 11 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.89586 cm} x{4.08114 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Declare}} \tn % Row 0 \SetRowColor{LightBackground} public & everyone can see \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} privet & only child can inderectly interact \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{protected} & only child can see \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} static & static means it belongs to the class not an instance \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} final & cannot be changed \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Access}} modifiers: public, protected, and private \newline Modifier {\bf{requiring override}}: abstract \newline Modifier restricting to {\bf{one instance}}: static \newline Modifier {\bf{prohibiting}} value {\bf{modification}}: final\{\{nl\}\} \newline final double CM\_PER\_INCH = 2.54; \newline -{}-{}-{}-{}-{}-{}- \newline final double CM\_PER\_INCH; \newline CM\_PER\_INCH = 2.54;\{\{bb\}\} \newline -{}-{}-{}-{}-{}-{}- \newline public static final double PI = 3.1415;\{\{bb\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Object Assignment and Garbage}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{• Object variables are always references \newline • Assignment assigns references \newline • Java has automatic garbage collection} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Inheritance}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{• Inheritance through an extended (derived) class supports code reuse \newline % Row Count 2 (+ 2) • All classes in Java are directly or indirectly subclasses of the "Object" class \newline % Row Count 4 (+ 2) • "the default constructor", "equals" and, "toString" are a method of the Object class \newline % Row Count 7 (+ 3) • Using the reserved word, {\bf{super}}, one can access a parent class' constructor(s) , methods and instance data \newline % Row Count 10 (+ 3) • An object that refers to part of itself within its own methods can use {\bf{this}} reserved words to denote this relationship \newline % Row Count 13 (+ 3) •The expressions that are passed to a method in an {\bf{invocation}} are actual parameters% Row Count 15 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{parent class ~ ~ ~ ~ child class \newline base class ~ ~ ~ ~ ~ driver class \newline super class ~ ~ ~ ~ extended class} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{{\bf{Unified Modeling Language}}}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/noxlupus_1523228660_uml_key.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Loops}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{all three loop (do, while, for) statements are functionally equivalent} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} while(x==y)\{ \{\{nl\}\} stuff\} & \{\{bl\}\}as long as teh conditoin is true it will run \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} do\{ \{\{nl\}\} stuff \{\{nl\}\} \}while(x!=y) & \{\{bl\}\}the do loop is the same as the while exsept it will exacte at lest once \tn % Row Count 9 (+ 4) % Row 3 \SetRowColor{white} for(x;y;z)\{ \{\{nl\}\} stuff\} & x = inst; y = condistoin; z = chang; \{\{nl\}\} it checks the \{\{bl\}\}condishtoin then dose the chang \tn % Row Count 14 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\{\{link="https://www.developer.com/java/data/using-different-types-of-java-loops-looping-in-java.html"\}\}Loop Sitet\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{object-oriented programming}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{encapsulation}}, {\emph{inheritance}}, {\emph{polymorphism}} are the main programming mechanisms that constitute object-oriented programming} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Polymorphism: achieved by overriding} \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{inheritance:} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{polymorphism:} \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}