Object-Oriented Programming 4

790 views

Published on

Objects & Classes

Published in: Education, Technology, Sports
  • Be the first to comment

  • Be the first to like this

Object-Oriented Programming 4

  1. 1. CHAPTER 4OBJECTS & CLASSESMr.Warawut Khangkhane-Mail: awarawut@hotmail.comSocial Media: www.facebook.com/AjWarawut
  2. 2. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 2
  3. 3. F F F Mr.Warawut Khangkhan F Chapter 4 Objects & ClassesTop-Down Bottom-Up F F ˈ FF F F F (Information Hiding) F ˆ F F F F 3 (Encapsulation)
  4. 4. OBJECTS & CLASSES Mr.Warawut KhangkhanClass Fobject F F F Chapter 4 Objects & ClassesObject F F F , ,F F 4
  5. 5. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 5 Class nameOBJECTS & CLASSES Attribute Method
  6. 6. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 6OBJECTS & CLASSES
  7. 7. OOP Mr.Warawut KhangkhanAbstraction – ˈ F F F Fclass ˈ F F F Chapter 4 Objects & Classes F F F attribute methodEncapsulation – ˈ F F F F F F F classInheritance – ˈ F class attribute method class F FclassPolymorphism – ˈ F 7class F
  8. 8. Mr.Warawut Khangkhan Chapter 4 Objects & Classes Objects & Classes F CLASS 8
  9. 9. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 9F CLASS attribute method class
  10. 10. CLASS Mr.Warawut Khangkhan[ modifier ] class className { [ attributeName ] Chapter 4 Objects & Classes [ methodName ]}public class Student { …} 10
  11. 11. ATTRIBUTE Mr.Warawut Khangkhan[ modifier ] dataType attributeName ; Chapter 4 Objects & Classespublic class Student { String name; int age;} 11
  12. 12. METHOD Mr.Warawut Khangkhan[ modifier ] returnType methodName([parameter]) { Chapter 4 Objects & Classes [ method_body ] varValue; return varValue;}; 12
  13. 13. METHOD Mr.Warawut Khangkhanpublic class Student { String name; Chapter 4 Objects & Classes int age; public void setData( ) { setData( “Warawut Warawut”; name = “Warawut”; 50; age = 50; } getData( public void getData( ) { System.out.println(“Name: System.out.println(“Name: ” + name); System.out.println(“Age: System.out.println(“Age: ” + age); }} 13
  14. 14. Mr.Warawut Khangkhan Chapter 4 Objects & Classes Objects & Classes CLASS F 14
  15. 15. OBJECT Mr.Warawut Khangkhan[ modifier ] className objectName; objectName; Chapter 4 Objects & Classes F objectobjectName = new className( ); className( F object F[ modifier ] className objectName = className(new className( ); 15
  16. 16. F CLASS Mr.Warawut KhangkhanobjectName.attributeName;objectName.attributeName; Chapter 4 Objects & Classes method F FobjectName.methodName( [argument] );objectName.methodName( method FdataType methodValue =objectName.methodName(objectName.methodName( [argument] ); 16
  17. 17. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 17
  18. 18. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 18
  19. 19. Mr.Warawut Khangkhan Chapter 4 Objects & Classes Chapter 4 Objects & Classes MODIFIER JAVA 19
  20. 20. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 20JAVAMODIFIER
  21. 21. MODIFIER JAVA Mr.Warawut KhangkhanNon Access ModifierAccess Modifier Chapter 4 Objects & Classes 21
  22. 22. NON ACCESS MODIFIER Mr.Warawut Khangkhan key word F F F F F class F Chapter 4 Objects & Classes static F ˈ key word F attribute method ˈ static modifier final F ˈ key word F attribute class ˈ final modifier 22
  23. 23. NON ACCESS MODIFIER -STATIC Mr.Warawut Khangkhan attribute ˈ static F Chapter 4 Objects & Classes F F F object method ˈ static F F F class F class F class F F F F object 23
  24. 24. NON ACCESS MODIFIER -FINAL Mr.Warawut Khangkhan attribute F F F Chapter 4 Objects & Classes class F F class F 24
  25. 25. ACCESS MODIFIER Mr.Warawut Khangkhan key word F F F ˈ F F class Chapter 4 Objects & Classes ˂ F class F class F F 25
  26. 26. ACCESS MODIFIER Mr.Warawut Khangkhan F Access Modifier ˈ 4 Chapter 4 Objects & Classes public F F F class private F F F class F protected F F F class class package F F F class class F package 26
  27. 27. Mr.Warawut Khangkhan Chapter 4 Objects & Classes Objects & Classes PRIVATE F 27
  28. 28. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 28
  29. 29. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 29
  30. 30. Mr.Warawut Khangkhan Chapter 4 Objects & Classes Objects & Classes PROTECTED F 30
  31. 31. Mr.Warawut Chapter 4 Objects & Classes Khangkhan 31

×