Java object oriented programming (encapsulation / Inheritance / polymorphism) instance parsing
This paper mainly introduces the analysis of three object-oriented feature examples. Let's see the specific content.
encapsulation
Encapsulate a teacher and student class
Student class
Test class
Output results:
Name = Zhang San, age = 21, course = [Asda, yes, probably, too tempting], interest = playing name = Wang Wu, professional direction = Asda, course taught = Asda, teaching age = 99
inherit
Define play, taoistprime, master, warrior
Test class
Output results:
polymorphic
Server, client interaction
LoginListener
MyLoginListener
Server
Test class
Output results
summary
The above is about java object-oriented programming in this article (encapsulation, inheritance, polymorphism) all the contents of instance parsing, hope to help you. Interested friends can continue to refer to this site: parsing synchronized locked objects of Java programming, object-oriented programming ideas of Java language, detailed explanation of object instances, etc. if there are deficiencies, please leave a message. Thank you for your support to this site!