C03043 Ch02 Java Review
C03043 Ch02 Java Review
DEVELOPMENT
JAVA Review
• If you already known Java you may be bored by some parts of this lesson!
• You can move quickly through this material to prepare for the next lesson
9/23/20 Mobile Application Development
3
Copyright Notice
Learning Object
JAVA OVERVIEW
9/23/20 Mobile Application Development
6
• The Java Collections Framework uses generic classes & interfaces extensively
9/23/20 Mobile Application Development
19
String reference
variable
9/23/20 Mobile Application Development
22
Call Stack
IOException {…}
stack to find
calls exception
handler
method3() throws
IOException {…}
Throws
calls IOException
method4() throw
IOException {…}
JAVA OOP
9/23/20 Mobile Application Development
24
OOP
Polymorphism Inheritance
9/23/20 Mobile Application Development
25
Abstraction
Abstraction
• Abstraction is an essential part
of all object-oriented
programming languages
• It emphasizes what's important
OOP
& de-emphasizes what’s
unimportant at a particular
level of detail
Polymorphism Inheritance
9/23/20 Mobile Application Development
26
39
9/23/20 Mobile Application Development
27
Data abtraction
• Data Abstraction is the property by virtue of which only the essential details
are displayed to the user.
• Data Abstraction may also be defined as the process of identifying only the
required characteristics of an object ignoring the irrelevant details.
A class can extend only one abstract class. A class can implement more than one interface.
It is ideal for code reuse and evolution perspective. It is ideal for Type declaration.
9/23/20 Mobile Application Development
33
Advantages of Abstraction
Inheritance Abstraction
• OO languages enhance reuse by
allowing classes to inherit commonly
used state & behavior from other
classes OOP
Polymorphism Inheritance
9/23/20 Mobile Application Development
36
Inheritance
• Super Class: The class whose features are inherited is known as super
class(or a base class or a parent class).
• Sub Class: The class that inherits the other class is known as sub class(or a
derived class, extended class, or child class). The subclass can add its own
fields and methods in addition to the superclass fields and methods.
• Reusability: Inheritance supports the concept of “reusability”, i.e. when we
want to create a new class and there is already a class that includes some of
the code that we want, we can derive our new class from the existing class.
By doing this, we are reusing the fields and methods of the existing class.
9/23/20 Mobile Application Development
37
9/23/20 Mobile Application Development
38
Type of Inheritance
9/23/20 Mobile Application Development
39
• Java Collections Framework demonstrates capabilities & benefits of inheritance
9/23/20 Mobile Application Development
40
• The List hierarchy are collections
that maintain an ordering for
their elements
9/23/20
Overview of Java’s Support Mobile Application Development 28
forthatInheritance
• Subclasses don’t explicitly Object
extend a super class implicitly
inherit from java.lang.Object, e.g. hashCode();
equals();
• java.lang.Process implicitly wait()
extends java.lang.Object notify();
• All instances of java.lang.Process notifyAll();
therefore also provide clients access …
to inherited java.lang.Object methods
Process
waitFor()
…
9/23/20 Mobile Application Development 29
… …
… …
… …
9/23/20 Mobile Application Development 31
… …
… …
9/23/20
Overview of Java’s Support Mobile Application Development 32
for Inheritance
• java.lang.Object is the most general
Object
of all classes
• It serves as the root of a
hierarchy of classes available Abstract
Collection …
to Java apps
• Classes towards the bottom of
the inheritance hierarchy are Abstract
List …
more specialized
• e.g., List-related subclasses
override methods inherited Vector ArrayList
from super classes
LinkedList …
9/23/20 Mobile Application Development
46
Polymorphism Abstraction
• huanlq@hcmut.edu.vn