Chapter 6 OOP (Revision)

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Chapter 6 OOP (Revision) - Presentation Transcript

    1. Object-Oriented Programming with Java Oum Saokosal , Head of IT Department National Polytechnic Institute of Cambodia Tel: (855)-12-417214 E-mail: oum_saokosal@yahoo.com
    2. Chapter 6 Objects and Classes (Revision)
      • OOP
      • Classes
      • Objects
      • Constructors
      • Accessing Object’s Data and Methods
    3. Object-Oriented Programming
      • Why learning OOP?
        • Java is a pure OOP
        • OOP provides more flexibility, modularity, clarity, reusability
        • Other Programming: C++, C#, VB .NET, ActionScript 3.0, Ruby etc. also use OOP.
      • 3 concepts of OOP:
        • Class Encapsulation
        • Class Inheritance
        • Polymorphism
    4. Classes (1)
      • What is a class?
        • A class is similar to a template, blueprint or symbol (in Adobe Flash).
        • A class creates many objects.
      Class Objects
    5. Classes (2)
      • In a class, there are :
        • Data Fields (Properties)
        • Behavior:
          • Constructors
          • Methods
      public class Student { private int id, String name; public Student(){} public Student (int inputID, String inputName){ this.id = inputID; this.name = inputName; } public String toString(){ return id + name; } }
    6. Constructors (1)
      • What is constructor?
        • A constructor is to construct (create) objects from a class.
        • public class Student {
        • private int id, String name;
        • public Student(){}
        • public Student (int inputID,String inputName){
        • this.id = inputID;
        • this.name = inputName;
        • }
        • public String toString(){
        • return id + name;
        • }
        • }
    7. Constructors (2)
      • How to construct objects?
        • Usually, we have many classes in a projects. So the student class will be created in other classes.
        • To construct objects from student class:
        • public class TestStudent {
        • public static void main(String[] args){
        • Student stu;
        • //To construct an object
        • stu = new Student();
        • System.out.println(stu.toString());
        • }
        • }
    8. Access Object’s Data and Methods
      • To access method:
        • public class TestStudent {
        • public static void main(String[] args){
        • Student stu;
        • //To construct an object
        • stu = new Student(“123”,”Veasna”);
        • System.out.println( stu.toString() );
        • }
        • }
      • To access data:
        • Usually, We don’t access the data. If you like, you can do like : stu.id = 123 in case id is not private .
    9. End of Revision

    + OUM  SAOKOSALOUM SAOKOSAL, 2 months ago

    custom

    96 views, 1 favs, 0 embeds more stats

    Chapter 6 OOP (Revision)
    Taught by Oum Saokosal, He more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 96
      • 96 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 5
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories