UNIT 2 Using Objects et I
Java is an ECT oriented programing
language
Objects Singular entity that do the
actual week
OBJECTI
Physical properties Fields
Actions they can perform Methods
How they are created Constructors
Example
FlE
my Taxi maxNum Of Passengers
272 Value
ME HO
myTaxi drive Forward inputs
so no value void
OI
output return
CONSTRUCTOR
returns
Taxi new Taxi new Taxi inputs newly
created
reference y f TT 9 object
name new sane hare
data assignat 4 initiate
type operator keyword as nan
of type fields
Example
String mystring new
string Hello
reference
type
strings are objects like all
reference types
Static Non Static
Call it from Called from
the class names Objets
Ex Type methodC Ex Type name
new Type C j
name method C
Math string
Classy B used to define
for objects
a
type
typeName
Eapital
Xcode
as A
house
Blueprint
class object
available outside of file
y
I
put class Taxi
creating variable
Hariafbieedds fleeces
initialed Youuinitial
e int numpassengers
NOT P
availableprivate boolean is Convertible
tore private String make private String model
outside
object keyword for specify inputs
value
11methods no return my
available
for
void addPassengers intrigue
use this numPassengers 1 nun
Refers to this object
3 If does return type of return
public int current Nun Of Passages
return this nvm Passengers
Tkeyword to efm a valce
public veil makeAndModel C E
System.at printh this make 1 this model
Always hue the sane
constructor na as class
public tax list myboogenisonut Storing
my staring_mdDE
this nun Passengers nun
this is Concertible is Comet's
this make mk this model mdl
311 end of class
le
UNIT 2 using Objects et II
java long
Stringclasse Math class
methods stationed
length abscnzn
Returns number Returns absolute
of charades in Value of
main string input number
num't nu 2
index Of string
pow base expand
Returns location Returns num1
of a string raised to the
in main string
optional power of num2
substring start ezd sart nvm
Returns string Returns square
in original root of input
string based number
on range randomC
Compae To string 4 Returns random
Returns valve between
based on string 0 and I
as a
comparison doubt
stringdexes
Alvass
start IIe 220
www
at Ww
O 1 2345
0 1 2 34 s
Ex Ex
string mystring Ha Io Math abs 8.2
01234
s 7 I 8.21 8.2
mystring length
is 5
Math pwr 2,3
23 8
myStringindexoff'e I
D
myStringindexoff'a 1
D
Math Sart 9
if 3
myString substring 2,3 M Z
Math random
mystringcompareTo Bye D G m 0.9082567
My string
Escape Choracles
avon
Tine HI Yaacsias
My string is Ajay