You are on page 1of 6

Chapters :

1.
2.
3.
4.
5.
6.
7.

Breaking the Surface ...................................................... 34


A trip to Objectville .................................................... 60
Know your Variables .................................................. 82
How Object Behave .................................................. 104
Extra-Strength Methods ............................................ 128
Using the Java Library .............................................. 158
Better Living in Objectville ...................................... 198
8. Serious Polymorphism .............................................. 230
9. Life & Death of an Object ........................................ 268
10.
Numbers Matter ................................................... 306
11.
Risky Behaviour .................................................. 348
12.
A Very Graphic Story .......................................... 386
13.
Work on your Swing ........................................... 432
14.
Saving Objects .................................................... 462
15.
Make a Connection ............................................. 504
16.
Data Structures ................................................... 562
17.
Release your Code ............................................. 614
18.
Distributed Computing ...................................... 640
Appendix A : Final Code Kitchen ............................................... 682
Appendix B : Top 10 topics that almost made to the book ......... 692
source code available at wickedlysmart.com

CHAPTER 1 : BREAKING THE SURFACE

Source Code (.java file)

Compilation

Javac Compiler

Java Byte Code (.class file; machine-independent)

Interpretation

JVM

Output on any Java enabled device/ OS

W.O.R.A : Write Once Run Anywhere; implements portability


Note :

Unlike in C, integer & boolean are not compatible types in java.


Eg : int x = 1;
while(x) { }
// not allowed in java
boolean x = true;
while(x){ } // allowed
Array Declaration : String[] pet = { dog, cat, cow};
pet.length gives the no: elts in the array.

CHAPTER 2 : A TRIP TO OBJECTVILLE

The concept of abstraction & overriding has to do with inheritance.


Super-classes are more abstract while the sub-classes are more
specific.
Override = Redefine
When designing a class, think of what its object :
1. KNOWS (instance variables /state /data /fields /properties)
2. DOES
(methods / behaviour)
Class & Objects:
class is a blueprint for an obj; it tells d JVM how to make an obj
of tat type.
one class, many objects. Each obj has its own copy of the
instance variable.
A tester class is one which contains the main() which creates &
accesses the object of the newly created class.
Objects are created into the Heap (GarbageCollectible Heap).
2 Uses of main() :
1. to test the real class. ( main class is always in the tester class)
2. to launch / start the Java application.

Public + static = Global


In Java there is no concept of Global variables/methods. Instead
this is achieved by the use of public & static.
Static + final = Constant

CHAPTER 3 : KNOW YOUR VARIABLES

Variables are of 2 flavors :


1. Primitive ( boolean, char, byte, short, int, long, float, double)
2. Object Reference
Variables must have a name & type(primitive/reference)
Numberic Primitives :

int
short

byte

(-128

to 127)

long

16

(-32,768

to 32,767)

32

float

32
Character
Primitve :

char

(0

16

to 65,535)

64

double

64

Note :
float val = 32.4f
'f' needs to specified to declare a float, cz Java thinks anything with
a decimal point to be a double, unless 'f' is specified.
Int x = 20;
byte b = x;
// won't work
Although 20 is small enough to fit into a byte, the compiler only
sees the instruction as a 'larger' integer value trying to transfer
into a 'smaller' byte. Compiler doesn't consider the value '20'.

Compiler will not put value from a large cup(var) to a small one, but
allows from small to large.
Object Reference :

You might also like