\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{ivangcm01} \pdfinfo{ /Title (oca-java-7.pdf) /Creator (Cheatography) /Author (ivangcm01) /Subject (OCA Java 7 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}{310FA3} \definecolor{LightBackground}{HTML}{F2F0F9} \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{OCA Java 7 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{ivangcm01} via \textcolor{DarkBackground}{\uline{cheatography.com/30913/cs/9378/}}} \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}ivangcm01 \\ \uline{cheatography.com/ivangcm01} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 6th October, 2016.\\ Updated 6th October, 2016.\\ 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{1.29402 cm} x{3.68298 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Conceptos Basicos}} \tn % Row 0 \SetRowColor{LightBackground} Clase & Archivo escrito en lenguaje Java que modela atributos y metodos de un Objeto. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Objeto & Representación de una clase en tiempo de ejecución. \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} Estado & Valor de cada uno de los atributos en un momento dado. \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{Comportamiento} & Funcionalidad que provee una clase, se conforma por los metodos de la misma \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{Interfaces} & Contratos de comportamiento en POO \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.54924 cm} x{2.01388 cm} x{2.01388 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Modificadores de no acceso}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Nombre} & Metodo & Clase \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{Strictp} & Modifica la precision de la aritmetica flotante. & Modifica la precision de la aritmetica flotante de todos losmétodos. \tn % Row Count 7 (+ 5) % Row 2 \SetRowColor{LightBackground} Final & Garantiza que no sea sobreescrito. & Garantiza que la clase no sea extensible. \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{Abstract} & Permite omitir la implementación del método. & Permite a la clase tener 1-N métodos abstractos \tn % Row Count 13 (+ 3) % Row 4 \SetRowColor{LightBackground} \seqsplit{Native} & Implementacion dependiente de plataforma & \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} \seqsplit{Syncronized} & Garantiza que solo un hilo accedera al metodo en todo momento & \tn % Row Count 20 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Inclusión estatica.}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Función} & Provee de un atajo para no escribir los nombres completamentes cualificados para accesar a MIEMBROS estaticos \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \seqsplit{Syntaxis} & static import {\emph{.}}.*.MiembroEstatico \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} Ej. & import static java.lang.System.out; \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64241 cm} x{3.33459 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Asignación de literales enteras}} \tn % Row 0 \SetRowColor{LightBackground} Binarias & Comienzan con 0b ó 0B \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Octales & Comienzan con 0 \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Hexadecimal & Comienzan con 0x ó 0x \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Toda literal no fraccionaria es entera por defecto. \newline \newline Todo calculo entre literales ES ENTERO por defecto si al menos un operando es de tipo entero. \newline \newline Se aplica cast implicito a tipos de dato con menor tamaño de palabra} \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}{Asignación de literales Flotantes}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{DEBEN terminar con f ya que toda literal fraccionaria es doble por defecto Ej.10.05f} \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}{Identificadores legales}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Identificador de variable legal} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Un identificador legal tiene las siguientes caracteristicas:} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Debe comenzar por una letra o un simbolo(\$,\_), a partir del segundo caracter se permitira el uso de números.} \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Compilador de java}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Función} & Transformar archivos escritos en lenguaje Java({\emph{.java) en bytecode que la JVM puede entender y ejecutar (}}.class) \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Uso & javac {[}opciones{]} {[}archivos fuente{]} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.62655 cm} x{2.71505 cm} p{0.4177 cm} p{0.4177 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{5.377cm}}{\bf\textcolor{white}{Modificadores de acceso}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Nombre} & Funcion & Clase & \seqsplit{Metodo} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{public} & Provee acceso a todas las clases. & Si & Si \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{protected} & Provee acceso dentro del mismo paquete y a subclases en caso de existir & No & Si \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{default} & Provee acceso solo dentro del mismo paquete & Si & Si \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{private} & Garantiza el acceso solo dentro de la misma clase & No & Si \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}----} \SetRowColor{LightBackground} \mymulticolumn{4}{x{5.377cm}}{Se encuentran ordenados de mas permisivo a menos permisivo} \tn \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.04517 cm} x{3.93183 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Asignación de literales caracter}} \tn % Row 0 \SetRowColor{LightBackground} Unicode & '\textbackslash{}uxxx' \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{Caracter} & 'caracter' \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{Numerico} & Numero representable en 2 bytes \tn % Row Count 3 (+ 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}{Declaracion de Clases}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Debe cumplir con las siguientes reglas: \newline % Row Count 1 (+ 1) a) De tener una clase pública el nombre del archivo DEBE coincidir con la misma. \newline % Row Count 3 (+ 2) b) Si la clase pertenece a un paquete este debe estar especificado en la primera linea.% Row Count 5 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.74655 cm} x{4.23045 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{JVM}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Funcion} & Ejecutar programas una vez compilados. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Uso & java {[}opciones{]} {[}Nombre C.principal{]} {[}argumentos{]} \tn % Row Count 4 (+ 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}{Reglas de escritura de Interfaces}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{a) La syntaxis sera la siguiente: \newline % Row Count 1 (+ 1) \textless{}modificador\textgreater{}\textless{}abstract\textgreater{} interface nombre \textless{}extends int1,int2....\textgreater{} \newline % Row Count 3 (+ 2) b) Solo puede contener miembros constantes \newline % Row Count 4 (+ 1) \textless{}public\textgreater{}\textless{}static\textgreater{}\textless{}final\textgreater{} nombre \newline % Row Count 5 (+ 1) c) Todos sus métodos son implicitamente "public" "abstract" y NO permiten \newline % Row Count 7 (+ 2) modificadores de no acceso.% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{\textless{}\textgreater{} Engloban parametros opcionales.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Metodos de argumentos variables}} \tn % Row 0 \SetRowColor{LightBackground} Ejemplo de Syntaxis & void test(int ... t)\{\} \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Solo se permite uno por metodo y DEBE ser el último argumento.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.58804 cm} x{2.38896 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Declaracion de arreglos}} \tn % Row 0 \SetRowColor{LightBackground} Ej. arreglo con nombre & int a{[}{]}=new int{[}5{]}; / int a{[}{]}=\{1,2,3\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Ej. arreglo con nombre y bloque inicializador & int a{[}{]}=new int{[}{]}\{1,2\} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} Ej. arreglo anonimo & new int{[}{]}\{1,2\} \tn % Row Count 6 (+ 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}{Reglas de oro de la sobrecarga de metodos}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Una sobrecarga DEBE modificar los argumentos del método} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Una sobrecarga PUEDE modificar tipo de retorno o modificador de acceso} \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}