SlideShare a Scribd company logo
java
Java
OOP
•




•

          Problem Space)
class)
                                   object)
•                     scripting language

               Perl        PHP

•                                                     class
    members)                  properties)
                          member functions)
                               class { ... }

                                          class constructor
                                                       new
                           class constructor
Java
•

                          static
               instance
    instance
•            MyClass
           n     x             n
      static      Method 1         getX()
       instance
•

• MyClass a = new MyClass();
• MyClass b = new MyClass();
•                 instance
           x                                instance
                                              x

    instance)           n
                      static

       instance                         n
    reference                MyClass
          n
                                n              Class
    Variable"                                      n

    MyClass.n                instance
•               Method

    reference      Method


                    Method

                  MyClass)             instance
                             Method
    instance                     reference
                   Method
                                   static
•                   static             Method
• static                      Method
                        Method
                   instance

•                                printCircle
           TestPass1              instance
              printCircle            static
Java
constructor)
constructor)
•
          constructor)



    new
•   //DriveAcar05.java
    class Vehicle {
        int numberOfWheels ;
        boolean hasEngine ;
       //constructor
        Vehicle() {       // (1)
           numberOfWheels = 6 ;
           hasEngine = true ;
        }
        void run() {
            System.out.println("I am running") ;
       }
    }
    public class DriveAcar05 {
        public static void main(String[] args) {
           Vehicle myCar = new Vehicle() ;
           System.out.println("mycar has "+myCar.numberOfWheels+"Wheels.") ; // (2)
           System.out.println("That mycar has an engin is "+myCar.hasEngine+".") ; // (3)
        }
    }
•


                    void

•



                            DriveAcar05.java
       main()
          Vehicle          Vehicle myCar = new
    Vehicle();              Vehicle()

       numberOfWheels = 6       hasEngine =
•
•   //DriveAcar06.java
    class Vehicle {
        int numberOfWheels ;
        boolean hasEngine ;
       //constructor
        Vehicle() {
           numberOfWheels = 6 ;
           hasEngine = true ;
          System.out.println("A car has been built") ; // (1) notice this line
        }
        void run() {
            System.out.println("I am running") ;
       }
    }
    public class DriveAcar06 {
        public static void main(String[] args) {
           Vehicle myCar = new Vehicle() ;
           System.out.println("mycar has "+myCar.numberOfWheels+"Wheels.") ; // (2)
           System.out.println("That mycar has an engin is "+myCar.hasEngine+".") ; // (3)
        }
    }
Overloading Constructor)
•
•   //OverloadConstructor.java
    class Vehicle {
        int numberOfWheels ;
        boolean hasEngine ;
       //constructor and Overload Constructor
        Vehicle() {
            numberOfWheels = 6 ;
            hasEngine = true ;
           System.out.println("A car has been built") ; //notice this line
        }
        Vehicle(int number, boolean engine) {      // (1)
            numberOfWheels = number ;
            hasEngine = engine ;
           System.out.println("A car has been built") ; //notice this line
        }
        void run() {
             System.out.println("I am running") ;
       }
    }
    public class OverloadConstructor {
        public static void main(String[] args) {
            Vehicle myCar = new Vehicle(4,true) ;    // (2)
            System.out.println("mycar has "+myCar.numberOfWheels+"Wheels.") ;
            System.out.println("That mycar has an engin is "+myCar.hasEngine+".") ;
        }
    }
•   //TestThis.java                                this()
    class A {
       int a ;
       A() {
          a=0;
          System.out.println("Default constructor") ;
       }
       A(int i) {
           this() ;
           a=i;
          System.out.println("constructor 1 ") ;
       }
        A(int i, int j) {
            this(i+j) ;
            System.out.println("constructor 2 ") ;
•    }
    }
    public class DriveAcar06 {
       public static void main(String[] args) {
          System.out.println("Instantiate x");
          A x = new A() ;
          System.out.println("Variable a is "+ x.a) ;
          System.out.println("Instantiate y ");
           A y = new A(5) ;
          System.out.println("Variable a is "+ y.a) ;
           System.out.println("Instantiate z ");
           A z = new A(5,6) ;
           System.out.println("Variable a is "+ z.a) ;
       }
    }




               this()
Java
• static            File System          File System

                                     File Access
• File Access Component


• Set Fso= CreateObject("Scripting.FileSystemObject")
•                                      Fso
       File Access Component                Fso

• Open Text File Method
•


• Object.openTextFile(filename[,iomode][,create][,Format]
•
• Object
•   Filename
•   (          Required)
•   iomode
•   (            Optional)

• ForReading(1)
• ForWriting(2)
• ForAppending(8)

• Create
• (              optional)

• True

• False
                              Error
                             False
• Format
• (                  optional)                              Tristate
  UseDefault(-2)                                         ASCII
        ASCII
• Tristate True(-1)                    Unicode
• Tristate False(0)                    ASCII
•                                            ASCII
•
• Set fso= CreateObject("Scripting.FileSystemObject")
• Set Myfile=fso.openTextfile("c:testfile.txt",1, True)
•                                        fso
                 File Access                   fso
  OpenTextFile                 testfile.txt

•                                              OpenTextFile
                                MyFile                             Text
  Stream Object
• TextStream Object (                       Text)
                   TextStream
•   Close
•       TextStream Object
•   Read
•
•   ReadAll
•
•   ReadLine
•
•   Skip
•
•   SkipLine
•
• Write
•
• WriteLine
•
• WriteBlankLines
•
•   Sample1.asp
•   <% if request.form("message") = "" then %>
•   <html>
•   <body>
•   <form action="sample1.asp" method="post">
•   <font size=+1>
    text</font><br>
•   Name:
•   <input type=text name=message size=30>
•   <input type=submit value=
•     form>
•   <%
•   else
•   Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
•   MsgFile = Server.MapPath ("Text.txt")
•   Set OutStream= FileObject.CreateTextFile (MsgFile, True)
•   OutStream.WriteLine Request.Form("message")
•   Set OutStream = Nothing
•   Set MessageStr =Nothing
•   %>
•              a href="sample2.asp">sample2.asp</a>
•     body>
•   </html>
•   <% end if %>
•

•   Out Put
•   Sample1.asp
•

•   <html>
•   <body>
•               br>
•   <%
•   Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
•   MsgFile = Server.MapPath ("Text.txt")
•   On Error Resume Next
•   Set InStream= FileObject.OpenTextFile (MSGFile, 1, False, False)
•   Response.Write Instream.ReadALL & "<BR>"
•   Set Instream=Nothing
•   %>
•   </body>
•   </html>
•

•

•   Out Put
•
Java
Java
Java

More Related Content

PDF
OOPs & Inheritance Notes
PDF
.NET Fest 2018. Дмитрий Иванов. Иммутабельные структуры данных в .NET: зачем ...
PPT
Best Guide for Javascript Objects
PPTX
Iniciando com jquery
PDF
Pavel kravchenko obj c runtime
PDF
Java Day-5
KEY
Objective-C Survives
PPT
OOPs & Inheritance Notes
.NET Fest 2018. Дмитрий Иванов. Иммутабельные структуры данных в .NET: зачем ...
Best Guide for Javascript Objects
Iniciando com jquery
Pavel kravchenko obj c runtime
Java Day-5
Objective-C Survives

What's hot (19)

PDF
Collections In Java
KEY
RubyistのためのObjective-C入門
PPTX
Session 15 - Collections - Array List
PDF
Scala: A brief tutorial
PPTX
An Overview of the Java Programming Language
PPT
Lesson3
PDF
C# Starter L02-Classes and Objects
PPTX
Web scraping using scrapy - zekeLabs
PDF
13 advanced-swing
PDF
Java Advanced Features
PPTX
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
PPT
J query introduction
PDF
javascript objects
PPTX
Session 09 - OOP with Java - Part 3
PDF
Few simple-type-tricks in scala
PDF
C# Starter L04-Collections
PDF
C++ nothrow movable types
PDF
Java Programming - 06 java file io
KEY
Metaprogramming Primer (Part 1)
Collections In Java
RubyistのためのObjective-C入門
Session 15 - Collections - Array List
Scala: A brief tutorial
An Overview of the Java Programming Language
Lesson3
C# Starter L02-Classes and Objects
Web scraping using scrapy - zekeLabs
13 advanced-swing
Java Advanced Features
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
J query introduction
javascript objects
Session 09 - OOP with Java - Part 3
Few simple-type-tricks in scala
C# Starter L04-Collections
C++ nothrow movable types
Java Programming - 06 java file io
Metaprogramming Primer (Part 1)
Ad

Viewers also liked (15)

DOCX
PDF
รูปภาพกิจกรรมโครงการฯพระราชดำริ(รากเทียม)
PPTX
Practical Online Reputation Management
PPS
Melhorandoasdinmicas prgeorge-120813142517-phpapp02
DOCX
ย อย6
PPTX
International SEO Best Practices
PPTX
Northwestern technologies media design concepts
PPT
Disaster Preparedness: What Renters Need to Know
PDF
2015展新綠能_LED燈具型錄
PPTX
Library Websites: Are You Meeting Your SEO Goals?
PPTX
India vs china Comparison
PPTX
완성2
PDF
極短篇故事文案寫作 徐苙萍
PDF
樂水智者要知道的事
รูปภาพกิจกรรมโครงการฯพระราชดำริ(รากเทียม)
Practical Online Reputation Management
Melhorandoasdinmicas prgeorge-120813142517-phpapp02
ย อย6
International SEO Best Practices
Northwestern technologies media design concepts
Disaster Preparedness: What Renters Need to Know
2015展新綠能_LED燈具型錄
Library Websites: Are You Meeting Your SEO Goals?
India vs china Comparison
완성2
極短篇故事文案寫作 徐苙萍
樂水智者要知道的事
Ad

Similar to Java (20)

PDF
Atlassian Groovy Plugins
PPTX
Java class 4
PPT
Core java concepts
PDF
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
PDF
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
PPTX
Classes, objects in JAVA
KEY
About java
PPTX
PPTX
Polymorphism
PPTX
Java class 3
PDF
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
PDF
A comparison between C# and Java
PPT
Core java
PDF
Mobile Software Engineering Crash Course - C02 Java Primer
PDF
Better Software: introduction to good code
KEY
1 the language essentials
ODP
1.2 scala basics
PDF
Lecture 4: Data Types
PPTX
CodeCamp Iasi 10 march 2012 - Practical Groovy
PDF
Groovy.Tutorial
Atlassian Groovy Plugins
Java class 4
Core java concepts
Building Atlassian Plugins with Groovy - Atlassian Summit 2010 - Lightning Talks
CodeFest 2010. Иноземцев И. — Fantom. Cross-VM Language
Classes, objects in JAVA
About java
Polymorphism
Java class 3
Mixing Source and Bytecode: A Case for Compilation By Normalization (OOPSLA 2...
A comparison between C# and Java
Core java
Mobile Software Engineering Crash Course - C02 Java Primer
Better Software: introduction to good code
1 the language essentials
1.2 scala basics
Lecture 4: Data Types
CodeCamp Iasi 10 march 2012 - Practical Groovy
Groovy.Tutorial

More from JAy YourJust'one (15)

DOCX
งานย อยท _ 6 ต__งคำถาม java
DOCX
ซัมซุงนัดต้นปีเปิดตัว
DOC
เกมจับคู่5
DOC
เกมจับคู่4
DOC
เกมจับคู่4
DOC
เกมจับคู่3
DOC
เกมจับคู่2
DOC
เกมจับคู่1
DOC
แต่งกลอนภุชงคประยาตฉัน11
DOC
ฮาร์ดไดรฟ์ปลอม
DOC
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
DOC
การค้นหาข่าวสารในแวดวง I
งานย อยท _ 6 ต__งคำถาม java
ซัมซุงนัดต้นปีเปิดตัว
เกมจับคู่5
เกมจับคู่4
เกมจับคู่4
เกมจับคู่3
เกมจับคู่2
เกมจับคู่1
แต่งกลอนภุชงคประยาตฉัน11
ฮาร์ดไดรฟ์ปลอม
Samsung nc215 โน้ตบุ๊คพลังงานแสงอาทิตย์
การค้นหาข่าวสารในแวดวง I

Java

  • 3. OOP • • Problem Space)
  • 4. class) object) • scripting language Perl PHP • class members) properties) member functions) class { ... } class constructor new class constructor
  • 6. static instance instance
  • 7. MyClass n x n static Method 1 getX() instance • • MyClass a = new MyClass(); • MyClass b = new MyClass();
  • 8. instance x instance x instance) n static instance n reference MyClass n n Class Variable" n MyClass.n instance
  • 9. Method reference Method Method MyClass) instance Method instance reference Method static
  • 10. static Method • static Method Method instance • printCircle TestPass1 instance printCircle static
  • 13. constructor) • constructor) new
  • 14. //DriveAcar05.java class Vehicle { int numberOfWheels ; boolean hasEngine ; //constructor Vehicle() { // (1) numberOfWheels = 6 ; hasEngine = true ; } void run() { System.out.println("I am running") ; } } public class DriveAcar05 { public static void main(String[] args) { Vehicle myCar = new Vehicle() ; System.out.println("mycar has "+myCar.numberOfWheels+"Wheels.") ; // (2) System.out.println("That mycar has an engin is "+myCar.hasEngine+".") ; // (3) } }
  • 15. void • DriveAcar05.java main() Vehicle Vehicle myCar = new Vehicle(); Vehicle() numberOfWheels = 6 hasEngine =
  • 16.
  • 17. //DriveAcar06.java class Vehicle { int numberOfWheels ; boolean hasEngine ; //constructor Vehicle() { numberOfWheels = 6 ; hasEngine = true ; System.out.println("A car has been built") ; // (1) notice this line } void run() { System.out.println("I am running") ; } } public class DriveAcar06 { public static void main(String[] args) { Vehicle myCar = new Vehicle() ; System.out.println("mycar has "+myCar.numberOfWheels+"Wheels.") ; // (2) System.out.println("That mycar has an engin is "+myCar.hasEngine+".") ; // (3) } }
  • 19. //OverloadConstructor.java class Vehicle { int numberOfWheels ; boolean hasEngine ; //constructor and Overload Constructor Vehicle() { numberOfWheels = 6 ; hasEngine = true ; System.out.println("A car has been built") ; //notice this line } Vehicle(int number, boolean engine) { // (1) numberOfWheels = number ; hasEngine = engine ; System.out.println("A car has been built") ; //notice this line } void run() { System.out.println("I am running") ; } } public class OverloadConstructor { public static void main(String[] args) { Vehicle myCar = new Vehicle(4,true) ; // (2) System.out.println("mycar has "+myCar.numberOfWheels+"Wheels.") ; System.out.println("That mycar has an engin is "+myCar.hasEngine+".") ; } }
  • 20. //TestThis.java this() class A { int a ; A() { a=0; System.out.println("Default constructor") ; } A(int i) { this() ; a=i; System.out.println("constructor 1 ") ; } A(int i, int j) { this(i+j) ; System.out.println("constructor 2 ") ;
  • 21. } } public class DriveAcar06 { public static void main(String[] args) { System.out.println("Instantiate x"); A x = new A() ; System.out.println("Variable a is "+ x.a) ; System.out.println("Instantiate y "); A y = new A(5) ; System.out.println("Variable a is "+ y.a) ; System.out.println("Instantiate z "); A z = new A(5,6) ; System.out.println("Variable a is "+ z.a) ; } } this()
  • 23. • static File System File System File Access • File Access Component • Set Fso= CreateObject("Scripting.FileSystemObject") • Fso File Access Component Fso • Open Text File Method • • Object.openTextFile(filename[,iomode][,create][,Format] • • Object
  • 24. Filename • ( Required) • iomode • ( Optional) • ForReading(1) • ForWriting(2) • ForAppending(8) • Create • ( optional) • True • False Error False
  • 25. • Format • ( optional) Tristate UseDefault(-2) ASCII ASCII • Tristate True(-1) Unicode • Tristate False(0) ASCII • ASCII • • Set fso= CreateObject("Scripting.FileSystemObject") • Set Myfile=fso.openTextfile("c:testfile.txt",1, True) • fso File Access fso OpenTextFile testfile.txt • OpenTextFile MyFile Text Stream Object • TextStream Object ( Text) TextStream
  • 26. Close • TextStream Object • Read • • ReadAll • • ReadLine • • Skip • • SkipLine •
  • 27. • Write • • WriteLine • • WriteBlankLines •
  • 28. Sample1.asp • <% if request.form("message") = "" then %> • <html> • <body> • <form action="sample1.asp" method="post"> • <font size=+1> text</font><br> • Name: • <input type=text name=message size=30> • <input type=submit value= • form>
  • 29. <% • else • Set FileObject = Server.CreateObject("Scripting.FileSystemObject") • MsgFile = Server.MapPath ("Text.txt") • Set OutStream= FileObject.CreateTextFile (MsgFile, True) • OutStream.WriteLine Request.Form("message") • Set OutStream = Nothing • Set MessageStr =Nothing • %> • a href="sample2.asp">sample2.asp</a> • body> • </html> • <% end if %> • • Out Put
  • 30. Sample1.asp • • <html> • <body> • br> • <% • Set FileObject = Server.CreateObject("Scripting.FileSystemObject") • MsgFile = Server.MapPath ("Text.txt") • On Error Resume Next • Set InStream= FileObject.OpenTextFile (MSGFile, 1, False, False) • Response.Write Instream.ReadALL & "<BR>" • Set Instream=Nothing • %> • </body> • </html> • • • Out Put •