- 2

What is OOP and explain with example?

I want to know about OOP.

17th Apr 2017, 6:20 AM
Si Thu Mg Mg 🇲🇲
Si Thu Mg Mg 🇲🇲 - avatar
2 Answers
+ 3
We are human. Humans are animal. Animals are biological. Biologicals are object. Finally, all the things in the world are "Object". For Java, we can explain it as... public class Human extends Animal { public void talk ( ) { System.out.println ( "say hello." ) ; } public void think ( ) { System.out.println ( "I'm thinking." ) ; } } public class Animals extends Biological { public void eat ( ) { System.out.println ( "I'm eating" ) ; } } public class Biological { // public class Biological extends Object { /* All the classes is derived class of Object ** So extends Object is not necessary */ public Biological breed ( ) { return new Biological ( ) ; } } The Human inherits the Animal and Biological. So the Human have the methods talk, think, eat, breed. The above is the basic concept of OOP.
17th Apr 2017, 8:16 AM
K.C. Leung
K.C. Leung - avatar
17th Apr 2017, 7:12 AM
Yaroslav Pieskov
Yaroslav Pieskov - avatar