Object Essentials

29 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€48.05
List Price:  €67.28
You save:  €19.22
£39.88
List Price:  £55.84
You save:  £15.95
CA$71.90
List Price:  CA$100.66
You save:  CA$28.76
A$80.21
List Price:  A$112.30
You save:  A$32.09
S$67.90
List Price:  S$95.06
You save:  S$27.16
HK$388.30
List Price:  HK$543.65
You save:  HK$155.35
CHF 44.96
List Price:  CHF 62.95
You save:  CHF 17.98
NOK kr568.59
List Price:  NOK kr796.08
You save:  NOK kr227.48
DKK kr358.52
List Price:  DKK kr501.96
You save:  DKK kr143.43
NZ$88.63
List Price:  NZ$124.09
You save:  NZ$35.46
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.46
৳5,964.32
List Price:  ৳8,350.53
You save:  ৳2,386.20
₹4,261.53
List Price:  ₹5,966.48
You save:  ₹1,704.95
RM223.40
List Price:  RM312.78
You save:  RM89.38
₦77,264.54
List Price:  ₦108,176.54
You save:  ₦30,912
₨13,894.99
List Price:  ₨19,454.09
You save:  ₨5,559.10
฿1,708.65
List Price:  ฿2,392.25
You save:  ฿683.60
₺1,762.73
List Price:  ₺2,467.97
You save:  ₺705.23
B$337.26
List Price:  B$472.19
You save:  B$134.93
R931.25
List Price:  R1,303.83
You save:  R372.57
Лв94.03
List Price:  Лв131.65
You save:  Лв37.62
₩73,236.45
List Price:  ₩102,536.89
You save:  ₩29,300.44
₪183.18
List Price:  ₪256.46
You save:  ₪73.28
₱2,897.69
List Price:  ₱4,057
You save:  ₱1,159.31
¥7,870.45
List Price:  ¥11,019.26
You save:  ¥3,148.81
MX$1,008.39
List Price:  MX$1,411.83
You save:  MX$403.43
QR181.52
List Price:  QR254.14
You save:  QR72.62
P693.18
List Price:  P970.50
You save:  P277.32
KSh6,450.70
List Price:  KSh9,031.50
You save:  KSh2,580.80
E£2,544.44
List Price:  E£3,562.42
You save:  E£1,017.98
ብር6,354.82
List Price:  ብር8,897.26
You save:  ብር2,542.43
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$49,495.04
List Price:  CLP$69,297.02
You save:  CLP$19,801.98
CN¥364.87
List Price:  CN¥510.85
You save:  CN¥145.97
RD$3,040.26
List Price:  RD$4,256.60
You save:  RD$1,216.34
DA6,759.94
List Price:  DA9,464.46
You save:  DA2,704.52
FJ$115.90
List Price:  FJ$162.28
You save:  FJ$46.37
Q384.44
List Price:  Q538.26
You save:  Q153.81
GY$10,442.13
List Price:  GY$14,619.81
You save:  GY$4,177.68
ISK kr6,972.60
List Price:  ISK kr9,762.20
You save:  ISK kr2,789.60
DH503.31
List Price:  DH704.68
You save:  DH201.36
L918.76
List Price:  L1,286.35
You save:  L367.58
ден2,958.22
List Price:  ден4,141.74
You save:  ден1,183.52
MOP$399.27
List Price:  MOP$559.01
You save:  MOP$159.74
N$928.04
List Price:  N$1,299.34
You save:  N$371.29
C$1,836.54
List Price:  C$2,571.30
You save:  C$734.76
रु6,797.51
List Price:  रु9,517.06
You save:  रु2,719.54
S/185.85
List Price:  S/260.20
You save:  S/74.35
K202.57
List Price:  K283.61
You save:  K81.04
SAR187.68
List Price:  SAR262.77
You save:  SAR75.08
ZK1,381.27
List Price:  ZK1,933.89
You save:  ZK552.61
L239.13
List Price:  L334.80
You save:  L95.67
Kč1,206.78
List Price:  Kč1,689.59
You save:  Kč482.80
Ft19,691.70
List Price:  Ft27,569.95
You save:  Ft7,878.25
SEK kr553.12
List Price:  SEK kr774.42
You save:  SEK kr221.29
ARS$51,256.54
List Price:  ARS$71,763.27
You save:  ARS$20,506.72
Bs344.88
List Price:  Bs482.86
You save:  Bs137.98
COP$220,805.67
List Price:  COP$309,145.61
You save:  COP$88,339.93
₡25,341.90
List Price:  ₡35,480.70
You save:  ₡10,138.79
L1,268.10
List Price:  L1,775.44
You save:  L507.34
₲389,249.85
List Price:  ₲544,980.94
You save:  ₲155,731.08
$U2,221.61
List Price:  $U3,110.44
You save:  $U888.82
zł204.99
List Price:  zł287
You save:  zł82.01
Already have an account? Log In

Transcript

Okay in this chapter we are going to go into the object oriented programming of Java. So, in this chapter we will cover object oriented programming. Why is grass Why is an object Why is property why they met does polymorphism why they matters and capsulation and why they matters inheritance okay object oriented programming as we differentiate between procedural and object oriented programming in chapter one, we mentioned that job is actually an object oriented programming language. So, how does object oriented programming involve object oriented programming represent a concept of objects and associated procedure or function known as method. Objects are the instance of process useful interaction with one another in the design of an application or program. As such object oriented programming provides that the organization and model import a real object in program design.

So, how do we create a class and object in the Java programming? So for our console calculator, we will create my mess class. So I will come to host package here in a new Java class my mix okay and finish that see why he's inside my mess cross. Okay, so in this class, I'm going to We organize organize all my co I'm going to put in order Massa calculation as a meta into this mess cross. Okay, so first I Korea ah first number second number okay na ba bus number ba ba second number and I'm going to create a property met a these are the property must get first number set first number get second number set second number Qaeda shoot ways to create the property matters here. He Okay Never mind I will create them.

So probably get first number okay. I think at first number should be taba. Okay, so I'm going to return these doc first number. So for Bri, Baba, guests first number, second number read these and number get out there. Get down we have guns sec okay Bri boy set for us number for us number k d days no first equal first number Bri boy say second number second number candies the second number it was again number okay then we should be Create another okay constructor method. I mess in my mess to toe contractor method.

Okay, Bobby, my mass plus constructor method. Then be my first number. Second number. Do you stop first number it will number the second set second Then we look to the okay the next one we will create order order meta for the mass calculation. So double sum and then we have Dabba samples number second number okay so fabri GABA some okay. So da bovie return these.

No first number, these second second number Bri na ba ba ba ba ba ba said Ken We can number okay Bobby, Bobby, Bobby substrate. Nice talk. First number, second. Number three subtract number, the second number we bus number minus set number Okay, this one should be minus top track pro die and deviation copy base some okay dhaba Proto. So this one should be times pro that this one should be times okay subtract deviation is one should be by deviation the song should be okay so I have created my own Class Okay, so now how are we going to add this math class into the console calculator? So we create a mess object and then we add in the we change our calculation by using the object some object method.

Okay? So I in this one okay? My mask and he knew Mine okay. The DVD number one, TV number two okay. Some I will change to em some is our choose to m dot subtract is our change to m.is on I will change to em the division. Okay.

I should be getting around the same result so I will run the Quincy Okay addition one okay first number one second number two okay results will be three yes this is correct. So this is I will say Rafi This is how we create a crossing the Java programming. So I will say a Y is a class. So a class is a footprint of an object, it consists of the following members. So, in class we have the class variables. Then we have the property matters you can see the other getters Are the sectors we've published modifier then we have the constructor then we have vectors.

So what is an object? An object is the instance of a class it can be the crest follows. So my mess is cross then VCA mth is the object or the other is the object and then equal new my mess. Cross. So this one, my mess is actually the constructor. Okay, this is the constructor.

So in a course Ah, in the console calculator course. I write my mess M equal new my mess dhaba first number, double second. Number so if we look into the my math class I am actually using this constructor method okay my mess the first number the second number so I'm using the same construct constructor Mehta my mess dhaba number one, number two. I'm using this constructor method. I can also use this constructor method. Just as you see I use the first one.

Then I have to set my own set of first number. Set, first number two dB, number one ladies. So second dbx I can also do this way by prefer to use the second quarter method without foster kill you he says Rafi wise ah ob Giada my mess object in the console calculator. Ky is an object and then to access the property and methods of the my mess object we can set to something empty Don't get first number and tears don't set the first number. So, get the first number is to retrieve the value of the first number below but in empty object and then set first number is to set a value of the first number in the object we can do mth talks some is to call the summit in my math class okay. So, in our my next class I will say get first time ba and then return this dot first time return the stock first number actually refer to the ISA class variable first number, return this dot second number refer to the these are class variables second number so to set the first time Number Ah, so we have this top first number, we should refer to the class variable first number equal this parameter the second number, so the same, the stocks that can number your photo this one equal to the paramita.

So in my constructor method one is the one constructor method don't have any parameters. And then the second constructor method I have two parameters first number and second number. So when I use this second constructor method, I actually set the first number class variable to the pyramid And the second number class variable to this parameter then I call the my mess class object dot sum that means I call in this method these dot first number you see is a cross first number brass this dot second number which is the cross second number Okay, I can do the other ways probably double sum and then I have some of the parameters. Then I guess redonda ah some of the parameters value. Some other parameters are the variables Okay then subtitles. So the same product also the same and then division also the same.

So, what is the property of the cluster property of a class is a member that provides a mechanism to read write or compute the value of private few available for Java properties and getters and setters method. So, get a variable one set variable one, so, we can have a private web Robo one here we have the get Robo one method and then set the robo one method. Okay, next we are going to talk about polling Pisani now object oriented programming polymorphism means having many forms. So polymorphism can also be method overloading. So, method overloading means, overloading take place when a few methods with the same name, but different parameters appear in the same class he offers some form or flexibility to our method. So, if we look into the mess class, so, this semester is actually over load the meta data first summit ah we have no parameters.

By the second summit we have some parameters inside these two meta rd have the same name. So, they are called overloading method Okay, so, how do we use the overloading method so, we can do something Id double resolve Annika m dot sum double result to equal m dot sum one to the book both have the same result they are both the same. Okay then next we will talk about encapsulation. So, a data storage within a class can be encapsulate or hidden. any external class can only access to the data using the meta sada property meta variable storing the sensitive data values can be encapsulated with modifiers as follows. So far poppy modifier it means The variable or the cross or the they can all be used or accessed from any anyplace.

But that means I can use or accessing containing classes or types derive internet can use all assessing current as embryo ni, private can use or SS in the continuing care Bondy. Okay, so next we talked about inheritance. Okay inheritance our definition of our class in terms of another class allows a derived class to inherit some members of the base class. He is the task of creating and maintaining an application and it provides reuse of code functionality and promote faster implementation time. So, how do we create inheritance So far ah console application console application or console calculator we are going to create a summation cross then we are going to inherit from the my next class okay I think we can try to create a summation class so I in the same class here okay submission okay puppet cross site to inherit from my mess class, we've had to use a stand my mess class okay.

So, we can see that we are doing this public class summation as stands my next class. Let me have that constructor method here. Then we have the get result method which is a summation method okay so povery submission This is the concept that we have a summation i get results integer SMT try by remove the integer as integer Why are because I'm going to use the first number and second number in my next class. So I removed this one. So I say should be integer S equal first number, first number, integer and integer y equals integer can now Okay first number second number so by era I'm sure we'll be okay non static variable. So, I have to remove the static okay.

So, this first number and second number actually is from these my next class first number second number ah why we can use the first number and second number in my mess cross is because our submission Class A standard my next class. So, this means that our submission inherits my next class. So, this is the strength of the inheritance in Java programming So I can implement summation class by doing something like this I don't think I can do em Boston here. By should be a total mission equals new submission by so few of you something essential be my meds, check core okay. So, I can do something like this summation sum equal new summation some set the first number to be DB number one some dos set set a number to be DB number two. Now I can do the submission though ah get results Okay, so this one should be the kingdom okay so we that I can ah Kampala And I can run the program again.

Okay, so number five. So first number one 100 I still get Pfizer, Pfizer Oh, this is the correct result. Okay. So with that we have come to the end of chapter five. In chapter five he covers our causes and objects polymorphism, encapsulation and inheritance. In the next chapter we are driving to test my name using Java

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.