Похожие презентации:
Object Oriented Programming
1.
Object Oriented Programming2.
Consider the following pointsWrapper Classes
Dates and Times
Inheritance
Encapsulation
Polymorphism
3.
Wrapper ClassesPrimitive type Wrapper class Example of constructing
boolean
Boolean
new Boolean(true)
byte
Byte
new Byte((byte) 1)
short
Short
new Short((short) 1)
int
Integer
new Integer(1)
long
Long
new Long(1)
float
Float
new Float(1.0)
double
Double
new Double(1.0)
char
Character
new Character(‘c’)
4.
Converting from a StringWrapper class Converting String to
Converting String to wrapper class
Boolean
Boolean.parseBoolean(“true”)
Boolean.valueOf(“true”)
Byte
Byte.parseByte(“1”)
Byte.valueOf(“2”)
Short
Short.parseShort(“1”)
Short.valueOf(“2”)
Integer
Integer.parseInt(“1”)
Integer.valueOf(“2”)
Long
Long.parseLong(“1”)
Long.valueOf(“2”)
Float
Float.parseFloat(“1”)
Float.valueOf(“2”)
Double
Double.parseDouble(“1”)
Double.valueOf(“2”)
Character
none
none
5.
Dates and Times6.
Periods7.
Formatting8.
Parsing Dates and Times9.
InheritanceInheritance is the process by which the new child subclass automatically
includes any public or protected primitives, objects or methods defined in the parent
class.
10.
EncapsulationEncapsulation in Java is a
mechanism of wrapping the data
(variables) and code acting on the data
(methods) together as a single unit. In
encapsulation, the variables of a class
will be hidden from other classes, and
can be accessed only through the
methods of their current class.
Therefore, it is also known as data hiding.
11.
Access Modifierspublic – from any class
protected – from classes in the same package or subclasses
default (package private) access - from classes in the same
package
private – from within the same class
12.
PolymorphismPolymorphism in Java is a concept by which we can perform a single
action in different ways.
There are two types of polymorphism in Java
compile-time
runtime
13.
OverloadingShould be different
types of parameters
numbers of parameters
Can be different
access modifiers
optional specifiers
return types
exception lists
14.
Order Java uses to choose theright overloaded method
1)Exact match by type
2)Larger primitive type
3)Autoboxed type
4)Varargs
15.
Overriding methods1) The method in the child class must have the same signature as the method
in the parent class
2) The method in the child class must be at least as accessible or more
accessible then the method in the parent class
3) If the method returns a value, it must be the same or a subclass of the
method in the parent class, known as covariant return types
4) The method defined in the child class must be marked as static if it is
marked as static in the parent class and otherwise.