\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{Dedicator9403} \pdfinfo{ /Title (java-interview-questions.pdf) /Creator (Cheatography) /Author (Dedicator9403) /Subject (Java Interview Questions 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}{2972C4} \definecolor{LightBackground}{HTML}{F1F6FB} \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{Java Interview Questions Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Dedicator9403} via \textcolor{DarkBackground}{\uline{cheatography.com/186788/cs/39054/}}} \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}Dedicator9403 \\ \uline{cheatography.com/dedicator9403} \\ \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 5th June, 2023.\\ 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{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basic}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Java language and platform}} & Java language : High level, Platform Independent, Portable \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & Java platform : JRE and API \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{JVM, JRE \& JDK}} & JVM : VM that provide specification for JRE. \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} & JRE : implementation of JVM where the byte code get executed. \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} & JDK : JRE + Tools (javac, javadoc, jar). \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} {\bf{Static}} & Static Variable : belong to class and get memory only once in class area at the time of class loading. \tn % Row Count 17 (+ 5) % Row 6 \SetRowColor{LightBackground} & Static Method : belong to class, cant use non static variables and methods inside if it is not known \tn % Row Count 22 (+ 5) % Row 7 \SetRowColor{white} & Static Block : initialize static variables and executed before main method at the time of class loading. \tn % Row Count 27 (+ 5) % Row 8 \SetRowColor{LightBackground} & Static Import : access any static member of a class directly. There is no need to qualify it by the class name in program. \tn % Row Count 33 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Basic (cont)}} \tn % Row 9 \SetRowColor{LightBackground} {\bf{Access Modifiers}} & Public \textgreater{} Protected \textgreater{} Default \textgreater{} Private \tn % Row Count 2 (+ 2) % Row 10 \SetRowColor{white} {\bf{Final}} & variable (can't change, constant), method(can't override), class (can't inherit) \tn % Row Count 7 (+ 5) % Row 11 \SetRowColor{LightBackground} {\bf{Package}} & group of similar classes, interface and sub package. \tn % Row Count 10 (+ 3) % Row 12 \SetRowColor{white} & java.lang package is imported implicitly( Throwable, Iterable, Comparable, Object). \tn % Row Count 14 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{STRING}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Java String}} & Immutable \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & Literals — stored in string constant pool(inside heap)intern() \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} & Object — stored directly in heap \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} & When the intern() method is executed then it checks whether the String equals to this String Object is in the pool or not. If it is available, then the string from the pool is returned. Otherwise, this String object is added to the pool and a reference to this String object is returned. \tn % Row Count 18 (+ 11) % Row 4 \SetRowColor{LightBackground} {\bf{StringBuffer}} & mutable \tn % Row Count 20 (+ 2) % Row 5 \SetRowColor{white} & thread safe and synchronized \tn % Row Count 21 (+ 1) % Row 6 \SetRowColor{LightBackground} & less efficient than StringBuilder \tn % Row Count 23 (+ 2) % Row 7 \SetRowColor{white} {\bf{StringBuilder}} & mutable \tn % Row Count 25 (+ 2) % Row 8 \SetRowColor{LightBackground} & non-synchronized,i.e., not thread safe \tn % Row Count 27 (+ 2) % Row 9 \SetRowColor{white} & more efficient than StringBuffer \tn % Row Count 29 (+ 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}{Object}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Every class in Java is directly or indirectly derived from the Object class.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{toString()}} : provides String representation of an Object. The default toString() method for class Object returns a string consisting of class name+@+unsigned hexadecimal representation of the hash code of the object.} \tn % Row Count 7 (+ 5) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{hashCode()}} : For every object, JVM generates a unique number which is hashcode.} \tn % Row Count 9 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{equals(Object obj)}} : Compares the given object to "this" object} \tn % Row Count 11 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{finalize()}} method : This method is called just before an object is garbage collected. It is called by the Garbage Collector on an object when garbage collector determines that there are no more references to the object.} \tn % Row Count 16 (+ 5) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{clone()}} : It returns a new object that is exactly the same as this object} \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\bf{wait()}}, {\bf{notify()}} {\bf{notifyAll()}} are related to Concurrency.} \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{OOP}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Object}} & real time entity with state and behavior. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Class}} & collection of similar Objects. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} & Constructor : special function used to initialize state of an object. No return Type but returns current instance of the class. Not inherited so cant make final. Called by super() method from child class.Cant have this() and Super() together in constructor as both should be the first statement. \tn % Row Count 15 (+ 11) % Row 3 \SetRowColor{white} & this : points current object, it is final type, can be used in synchronized block \tn % Row Count 18 (+ 3) % Row 4 \SetRowColor{LightBackground} {\bf{Encapsulation}} & wrapping data and associated function into single unit implements data hiding using private property accessed using getter and setter methods. \tn % Row Count 24 (+ 6) % Row 5 \SetRowColor{white} {\bf{Inheritance}} & mechanism by which one class acquire properties and behavior of another on class, Code re-usability. \tn % Row Count 28 (+ 4) % Row 6 \SetRowColor{LightBackground} & Super : points to parent class object. \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{OOP (cont)}} \tn % Row 7 \SetRowColor{LightBackground} {\bf{Polymorphism}} & same message can be processed in more than one form. \tn % Row Count 2 (+ 2) % Row 8 \SetRowColor{white} & Method Overloading : same function name but differ in number and type of arguments within the same class, Readability , Compile time. \tn % Row Count 7 (+ 5) % Row 9 \SetRowColor{LightBackground} & Method overriding : specific implementation of method in child class which is already defined in defined in parent class, Run time(only method not property). \tn % Row Count 13 (+ 6) % Row 10 \SetRowColor{white} & Covarient return type : child class method return type should be sub type of return type of parent class. \tn % Row Count 17 (+ 4) % Row 11 \SetRowColor{LightBackground} {\bf{Abstraction}} & implementation hiding using Abstract class and Interface. \tn % Row Count 20 (+ 3) % Row 12 \SetRowColor{white} & Abstract class : cant be instantiated, should have at least one abstract method, can have constructor(called by extended class constructor during object creation). \tn % Row Count 26 (+ 6) % Row 13 \SetRowColor{LightBackground} & Interface : no constructor and instance, public static final members. \tn % Row Count 29 (+ 3) % Row 14 \SetRowColor{white} & Tagged/Marker interface: no members defined, used to give mark/tag. eg: serializable, clonable. \tn % Row Count 33 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.4931 cm} x{3.4839 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{OOP (cont)}} \tn % Row 15 \SetRowColor{LightBackground} {\bf{Relation}} & Association : relationship where all objects have their own life-cycle \& there is no ownership. eg: teacher-student \tn % Row Count 5 (+ 5) % Row 16 \SetRowColor{white} & Aggregation : special type of association, separate life cycle but there is ownership eg : department- teacher \tn % Row Count 9 (+ 4) % Row 17 \SetRowColor{LightBackground} & Composition : Special type of aggregation, no separate life cycle and if parent deleted, all child will get delete. \tn % Row Count 14 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Collection}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Collection}} & Interface in java.util package extended Iterable interface. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} {\bf{List}} & maintain insertion order, include duplicate elements, can have null entry. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} & ArrayList : dynamic array, index based, best for store and fetch, increases size by half \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} & LinkedList : doubly linked list, best for adding and removing \tn % Row Count 13 (+ 3) % Row 4 \SetRowColor{LightBackground} {\bf{Queue}} & PriorityQueue, Dequeue-ArrayDequeue \tn % Row Count 15 (+ 2) % Row 5 \SetRowColor{white} & PriorityQueue : min/max heap \tn % Row Count 16 (+ 1) % Row 6 \SetRowColor{LightBackground} {\bf{Set}} & no duplicate elements \tn % Row Count 17 (+ 1) % Row 7 \SetRowColor{white} & HashSet : no order maintained, can have single null \tn % Row Count 19 (+ 2) % Row 8 \SetRowColor{LightBackground} & LinkedHashSet : insertion order maintained, can have single null \tn % Row Count 22 (+ 3) % Row 9 \SetRowColor{white} & TreeSet : sorted, no null value \tn % Row Count 24 (+ 2) % Row 10 \SetRowColor{LightBackground} {\bf{Map}} & key value pair, unique key \tn % Row Count 25 (+ 1) % Row 11 \SetRowColor{white} & HashMap : no order, can have single null key \tn % Row Count 27 (+ 2) % Row 12 \SetRowColor{LightBackground} & LinkedHashMap : insertion order, can have single null key \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Collection (cont)}} \tn % Row 13 \SetRowColor{LightBackground} & TreeMap : sorted based on key, can't have any null key \tn % Row Count 2 (+ 2) % Row 14 \SetRowColor{white} {\bf{Collections}} & java.util.Collections utility class \tn % Row Count 4 (+ 2) % Row 15 \SetRowColor{LightBackground} & Sorting : List by Collections.sort(), Set by converting to TreeSet, Map by converting to TreeMap, Need to implement Comparable or Comparator \tn % Row Count 9 (+ 5) % Row 16 \SetRowColor{white} & Comparable : lang, compareTo(), change base class, single sort logic \tn % Row Count 12 (+ 3) % Row 17 \SetRowColor{LightBackground} & Comparator : util, compare(), don't change base class, multiple sort logic \tn % Row Count 15 (+ 3) % Row 18 \SetRowColor{white} & Unmodifiable : unmodifiableCollection() return an unmodifiable view of the specified collection \tn % Row Count 19 (+ 4) % Row 19 \SetRowColor{LightBackground} {\bf{Legacy Class}} & all are synchronized and thread safe \tn % Row Count 21 (+ 2) % Row 20 \SetRowColor{white} & Property, Vector(increase size by double), Stack, HashTable(no null key and null value) \tn % Row Count 25 (+ 4) % Row 21 \SetRowColor{LightBackground} {\bf{Iteration}} & Iterator : legacy iteration support, list and set, can remove, forward only \tn % Row Count 28 (+ 3) % Row 22 \SetRowColor{white} & ListIterator : legacy iteration support, list, can remove and add, forward and backward \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Collection (cont)}} \tn % Row 23 \SetRowColor{LightBackground} & Enumerator : only for legacy support \tn % Row Count 2 (+ 2) % Row 24 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 2 (+ 0) % Row 25 \SetRowColor{LightBackground} & {\emph{To successfully store and retrieve objects from a Hashtable, the objects used as keys must implement the hashCode method and the equals method. Because hashcode used to find the bucket and equals used to replace existing value in that place of bucket.( if equals not overridden then it insert into a new LinkedList node that it use. It it total violation of rule as key are unique in map)}} \tn % Row Count 16 (+ 14) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{EXCEPTION HANDLING}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Throwable}} & exception and error \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} {\bf{Exception}} & can be handled using try-catch block or throws. \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} & checked and unchecked exception \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} {\bf{Checked exception}} & found at compile time. \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} & ClassNotFoundException, SQLException, IOException \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} {\bf{Unchecked exception}} & occur during run time. \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} & ArithematicException, NumberFormatException, NullPointerException, \seqsplit{ArrrayIndexOutOfBoundException}, \seqsplit{StringIndexOutOfBoundException} \tn % Row Count 18 (+ 6) % Row 7 \SetRowColor{white} {\bf{Error}} & cant be handled \tn % Row Count 19 (+ 1) % Row 8 \SetRowColor{LightBackground} & Irrecovarable \tn % Row Count 20 (+ 1) % Row 9 \SetRowColor{white} & StackOverflowError \tn % Row Count 21 (+ 1) % Row 10 \SetRowColor{LightBackground} {\bf{Finally }} & block after try/catch, always executed ( not if program exits) \tn % Row Count 24 (+ 3) % Row 11 \SetRowColor{white} {\bf{Throw }} & keyword, within method, followed by instance, single, cant propagate checked exception \tn % Row Count 28 (+ 4) % Row 12 \SetRowColor{LightBackground} {\bf{Throws }} & keyword, within method signature, followed by class, multiple, can propagate checked exception \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{EXCEPTION HANDLING (cont)}} \tn % Row 13 \SetRowColor{LightBackground} {\bf{Exception Overriding}} & if parent method not defined exception, child cant define checked exception but can define unchecked \tn % Row Count 5 (+ 5) % Row 14 \SetRowColor{white} & else child can define only sub class exception \tn % Row Count 7 (+ 2) % Row 15 \SetRowColor{LightBackground} {\bf{Try with resource}} & autoclosable \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.24425 cm} x{3.73275 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Concurrency}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Fail-fast}} & immediately throws \seqsplit{ConcurrentmodificationException}, if any structural modification occur \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.34379 cm} x{3.63321 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Generics}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Generic}} & Generics in programming languages, such as Java, allow the creation of classes, interfaces, and methods that can work with different types, providing flexibility and type safety. It enables the definition of generic algorithms and data structures that can be used with various types without sacrificing type checking at compile time. \tn % Row Count 12 (+ 12) % Row 1 \SetRowColor{white} {\bf{Wildcard(?)}} & Lower-bound \textless{}? super type\textgreater{} \tn % Row Count 14 (+ 2) % Row 2 \SetRowColor{LightBackground} & Upper-bound \textless{}? type\textgreater{} \tn % Row Count 15 (+ 1) % Row 3 \SetRowColor{white} & Unbound \textless{}?\textgreater{} \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Memory}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Types}} & Heap Area, Method Area, Stack, Native Method Stack \& PC Register \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & You can not force Garbage collection in Java. Though you can request it by calling Sytem.gc() or its cousin \seqsplit{Runtime.getRuntime().gc().} It's not guaranteed that GC will run immediately as result of calling these method \tn % Row Count 13 (+ 10) % Row 2 \SetRowColor{LightBackground} {\bf{Immutable Class Creation}} & Declare the class as final so it can't be extended. \tn % Row Count 16 (+ 3) % Row 3 \SetRowColor{white} & Make all fields private so that direct access is not allowed. \tn % Row Count 19 (+ 3) % Row 4 \SetRowColor{LightBackground} & Don't provide setter methods for variables \tn % Row Count 21 (+ 2) % Row 5 \SetRowColor{white} & Make all mutable fields final so that it's value can be assigned only once. \tn % Row Count 25 (+ 4) % Row 6 \SetRowColor{LightBackground} & Initialize all the fields via a constructor performing deep copy. \tn % Row Count 28 (+ 3) % Row 7 \SetRowColor{white} & Perform cloning of objects in the getter methods to return a copy rather than returning the actual object reference. \tn % Row Count 34 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Memory (cont)}} \tn % Row 8 \SetRowColor{LightBackground} {\bf{Deep Copy and Shallow Copy}} & The shallow copy is the approach when we only copy field values and therefore the copy might be dependent on the original object. \tn % Row Count 6 (+ 6) % Row 9 \SetRowColor{white} & In the deep copy approach, we make sure that all the objects in the tree are deeply copied, so the copy isn't dependent on any earlier existing object that might ever change. \tn % Row Count 14 (+ 8) \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}{SOLID Principles}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{S}}ingle Responsibility Principle & The Single Responsibility Principle states that a class should have only one reason to change, meaning it should have only one responsibility or job. In other words, a class should have a single purpose or focus. \tn % Row Count 11 (+ 11) % Row 1 \SetRowColor{white} {\bf{O}}pen-Closed Principle (OCP) & The Open-Closed Principle states that software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. In other words, the behavior of a software entity should be easily extendable without modifying its existing code. \tn % Row Count 25 (+ 14) % Row 2 \SetRowColor{LightBackground} {\bf{L}}iskov Substitution Principle (LSP): & The Liskov Substitution Principle states that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program. In other words, a subclass should be able to be used wherever its superclass is expected, without causing any unexpected behavior. \tn % Row Count 41 (+ 16) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SOLID Principles (cont)}} \tn % Row 3 \SetRowColor{LightBackground} {\bf{I}}nterface Segregation Principle (ISP): & The Interface Segregation Principle states that clients should not be forced to depend on interfaces they do not use. It suggests that interfaces should be specific to the needs of the clients, and no client should be obligated to depend on methods it does not need. \tn % Row Count 14 (+ 14) % Row 4 \SetRowColor{white} {\bf{D}}ependency Inversion Principle (DIP): & The Dependency Inversion Principle states that {\bf{high-level modules should not depend on low-level modules. Instead, both should depend on abstractions}}. It also states that abstractions should not depend on details; details should depend on abstractions. \tn % Row Count 27 (+ 13) \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}{Other Concepts}} \tn % Row 0 \SetRowColor{LightBackground} Dependency Injection & Dependency Injection is a design pattern used in software development to manage dependencies between objects. It allows the dependencies of a class to be provided externally, rather than having the class create or manage them internally. This pattern promotes loose coupling and makes the code more modular, testable, and maintainable. \tn % Row Count 17 (+ 17) % Row 1 \SetRowColor{white} Dependency Injection in Spring & Dependency Injection (DI) is a fundamental concept in the Spring framework, which provides a powerful and flexible way to manage dependencies in a Java application. Spring's DI container, also known as the Spring IoC (Inversion of Control) container, is responsible for instantiating and wiring dependencies for your application. \tn % Row Count 34 (+ 17) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Other Concepts (cont)}} \tn % Row 2 \SetRowColor{LightBackground} Lifecycle of a Spring bean & {\bf{1. Bean Definition}}: In this stage, the bean configuration is defined in either XML or Java-based configuration. It includes specifying the bean class, dependencies, and other properties. \tn % Row Count 10 (+ 10) % Row 3 \SetRowColor{white} & {\bf{2. Instantiation}}: During this stage, the Spring container creates an instance of the bean based on the bean definition. The container uses the bean's constructor or a factory method to create the object. \tn % Row Count 21 (+ 11) % Row 4 \SetRowColor{LightBackground} & {\bf{3. Dependency Injection}}: Once the bean is instantiated, the container injects any required dependencies into the bean. This can be done through constructor injection, setter injection, or field injection. \tn % Row Count 32 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Other Concepts (cont)}} \tn % Row 5 \SetRowColor{LightBackground} & {\bf{4. Bean Post-Processing}}: After dependency injection, Spring applies any registered BeanPostProcessors to modify the bean instance. BeanPostProcessors can perform tasks such as initializing proxy objects or adding additional behavior to the bean. \tn % Row Count 13 (+ 13) % Row 6 \SetRowColor{white} & {\bf{5. Initialization}}: At this stage, any initialization logic specified for the bean is executed. This can involve implementing the InitializingBean interface, defining custom initialization methods using annotations, or specifying initialization methods in the bean configuration. \tn % Row Count 28 (+ 15) % Row 7 \SetRowColor{LightBackground} & {\bf{6. Ready for Use}}: After initialization, the bean is ready for use. It can now respond to requests and perform its designated tasks. \tn % Row Count 35 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Other Concepts (cont)}} \tn % Row 8 \SetRowColor{LightBackground} & {\bf{7. Usage}}: During this stage, the bean is actively used by other components or services in the application. It carries out its assigned functionality and can be accessed and manipulated as needed. \tn % Row Count 10 (+ 10) % Row 9 \SetRowColor{white} & {\bf{8. Destruction}}: When the bean is no longer needed or when the application is shutting down, the container triggers the destruction of the bean. This involves executing any defined destruction logic, such as implementing the DisposableBean interface, specifying custom destruction methods using annotations, or defining destruction methods in the bean configuration. \tn % Row Count 29 (+ 19) % Row 10 \SetRowColor{LightBackground} Spring IoC (Inversion of Control) container & The Spring IoC (Inversion of Control) container is a core component of the Spring framework that manages the lifecycle and dependencies of objects (beans) in a Spring application. The IoC container is responsible for creating, configuring, and wiring the beans, allowing developers to focus on writing the business logic of their application. \tn % Row Count 47 (+ 18) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}