Network-centric
is the computer”
Designed for building applications for the
Internet
Object-oriented
model
Java Platform Editions
A Java Platform is the set of APIs, class libraries, and other programs
used in developing Java programs for specific applications
RuntimeException classes
are usually irrecoverable and not
handled explicitly
are not checked by the compiler
Checked Exceptions
are exceptions derived from Exception class
excluding the RuntimeException class
must be handled explicitly
Key Points
Exceptional conditions sometimes occur
in properly written code and must be
handled
Exception handling in Java is build
around the “throw-and-catch” paradigm
If a method can’t handle the exception,
it can propagate the exception to the
call stack
All exceptions are objects of Throwable
class
Defining a Class
A Class acts as the template from
which an instance of an object is
created. The class defines the
properties of the object and the
methods used to control the object's
behavior.
A Class specifies the structure of data
as well as the methods which
manipulate that data. Such data and
methods are contained in each
instance of the class.
Defining an Object
An object is a self-contained
entity
with
information attributes
an object must know: and
identity – uniqueness
behaviors
behavior an object must do:
methods – what it can do
attributes – structure events – what it responds to
state – current condition
Defining Abstraction
Abstraction is the process of
extracting common features from
specific examples
Abstraction is a process of defining the
essential concepts while ignoring the
inessential details
Different Types of Abstraction
Data Abstraction
Programming languages define constructs to
simplify the way information is presented to the
programmer.
Functional Abstraction
Programming languages have constructs that ‘gift
wrap’ very complex and low level instructions into
instructions that are much more readable.
Object Abstraction
OOP languages take the concept even further and
abstract programming constructs as objects.
Defining a Java Class
Clas Clas
s s
protected public
Classes that are in the All classes may access
package and all its Clas Clas public features of the
subclasses may access s s Sample class.
protected features of the
Sample class.
* Default is not a modifier; it is just the name of the access level if no access modifier is specified.
Accessibility Scope
Accessibility scope defines the boundary of access
to a class and its members
Scope Access
static static code can access static members
but not instance members
non- non-static code can access both static
static members and instance members
package a class and its members can be
accessed within the package they are
class declared
class members can be accessed within
the class
block local variables can be accessed only
within a block
•Encapsulation is the process of hiding an
object’s implementation from another object,
while presenting only the interfaces that should
be visible.
•Encapsulating a Class
can be used
implemented in Java by extending a class
“has-a” relationship
a whole-class relationship between a class and
its parts
also known as composition or aggregation
implemented in Java by instantiating an object
inside a class
“has-a” relationship
“is-a” relationship
Vehicle Car
Engine
Wheel
Car Bus
this and super
superclass
It cannot be assigned to other references, nor
implements
Set List
HashSet
SortedSet
extends
implements
“John” “Luke”
“Paul”
“Mark” “Fred”
“Peter”