SlideShare a Scribd company logo
1 of 13
STATIC METHODS AND
ABSTRACT CLASSES
PREPARED BY
V.SANTHI
ASSISTANT PROFESSOR,
DEPARTMENT OF COMPUTER APPLICATIONS,
THANJAVUR
STATIC METHODS:
THE STATIC KEYWORD IS USED TO DECLARE PROPERTIES AND METHODS OF A CLASS AS STATIC.
STATIC PROPERTIES AND METHODS CAN BE USED WITHOUT CREATING AN INSTANCE OF THE
CLASS. THE STATIC KEYWORD IS ALSO USED TO DECLARE VARIABLES IN A FUNCTION WHICH KEEP
THEIR VALUE AFTER THE FUNCTION HAS ENDED.
PHP- STATIC METHODS:
• STATIC METHODS CAN BE CALLED DIRECTLY - WITHOUT CREATING AN
INSTANCE OF THE CLASS FIRST.
• STATIC METHODS ARE DECLARED WITH THE STATIC KEYWORD:
SYNTAX:
• <?PHP
CLASS CLASSNAME {
PUBLIC STATIC FUNCTION STATICMETHOD() {
ECHO "HELLO WORLD!";
}
}
?>
EXAMPLE:
• <?PHP
CLASS GREETING {
PUBLIC STATIC FUNCTION WELCOME() {
ECHO "HELLO WORLD!";
}
}
// CALL STATIC METHOD
GREETING::WELCOME();
?>
OUTPUT:
• HELLO WORLD!
• EXAMPLE EXPLAINED
• HERE, WE DECLARE A STATIC METHOD: WELCOME(). THEN, WE CALL THE STATIC METHOD BY USING THE
CLASS NAME, DOUBLE COLON (:, AND THE METHOD NAME (WITHOUT CREATING AN INSTANCE OF THE
CLASS FIRST).
ABSTRACT CLASSES IN PHP:
• ABSTRACT CLASSES AND METHODS ARE WHEN THE PARENT CLASS HAS A
NAMED METHOD, BUT NEED ITS CHILD CLASS(ES) TO FILL OUT THE TASKS.
• AN ABSTRACT CLASS IS A CLASS THAT CONTAINS AT LEAST ONE ABSTRACT
METHOD. AN ABSTRACT METHOD IS A METHOD THAT IS DECLARED, BUT
NOT IMPLEMENTED IN THE CODE.
SYNTAX:
• <?PHP
ABSTRACT CLASS PARENTCLASS {
ABSTRACT PUBLIC FUNCTION SOMEMETHOD1();
ABSTRACT PUBLIC FUNCTION SOMEMETHOD2($NAME, $COLOR);
ABSTRACT PUBLIC FUNCTION SOMEMETHOD3() : STRING;
}
?>
EXAMPLE:
• <?PHP
// PARENT CLASS
ABSTRACT CLASS CAR {
PUBLIC $NAME;
PUBLIC FUNCTION __CONSTRUCT($NAME) {
$THIS->NAME = $NAME;
}
ABSTRACT PUBLIC FUNCTION INTRO() : STRING;
}
// CHILD CLASSES
CLASS AUDI EXTENDS CAR {
PUBLIC FUNCTION INTRO() : STRING {
RETURN “CHOOSE GERMAN QUALITY! I’M AN $THIS->NAME!”;
}
}
CLASS VOLVO EXTENDS CAR {
PUBLIC FUNCTION INTRO() : STRING {
RETURN “PROUD TO BE SWEDISH! I’M A $THIS->NAME!”;
}
}
CLASS CITROEN EXTENDS CAR {
PUBLIC FUNCTION INTRO() : STRING {
RETURN "FRENCH EXTRAVAGANCE! I'M A $THIS->NAME!";
}
}
// CREATE OBJECTS FROM THE CHILD CLASSES
$AUDI = NEW AUDI
ECHO $AUDI->INTRO();
ECHO "<BR>";
$VOLVO = NEW VOLVO("VOLVO");
ECHO $VOLVO->INTRO();
ECHO "<BR>";
$CITROEN = NEW CITROEN("CITROEN");
ECHO $CITROEN->INTRO();
?>
RESULT:
• CHOOSE GERMAN QUALITY! I'M AN AUDI!
PROUD TO BE SWEDISH! I'M A VOLVO!
FRENCH EXTRAVAGANCE! I'M A CITROEN!

More Related Content

Similar to static methods.pptx

Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaMOHIT AGARWAL
 
Complete list of all sap abap keywords
Complete list of all sap abap keywordsComplete list of all sap abap keywords
Complete list of all sap abap keywordsPrakash Thirumoorthy
 
OOP is more than Cars and Dogs
OOP is more than Cars and Dogs OOP is more than Cars and Dogs
OOP is more than Cars and Dogs Chris Tankersley
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpointwebhostingguy
 
Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Ahmad55ali
 
Intake 38 data access 3
Intake 38 data access 3Intake 38 data access 3
Intake 38 data access 3Mahmoud Ouf
 
Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1bharath yelugula
 
12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.ppt12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.pptVISHNUSHANKARSINGH3
 
Abap course chapter 7 abap objects and bsp
Abap course   chapter 7 abap objects and bspAbap course   chapter 7 abap objects and bsp
Abap course chapter 7 abap objects and bspMilind Patil
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_planMaria Colgan
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxVigneshkumar Ponnusamy
 
ABSTRACT CLASSES AND INTERFACES.ppt
ABSTRACT CLASSES AND INTERFACES.pptABSTRACT CLASSES AND INTERFACES.ppt
ABSTRACT CLASSES AND INTERFACES.pptJayanthiM15
 
Choose any multi-national organization that you would like to use .docx
Choose any multi-national organization that you would like to use .docxChoose any multi-national organization that you would like to use .docx
Choose any multi-national organization that you would like to use .docxchristinemaritza
 
MOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX ApplicationsMOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX ApplicationsMonica Li
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overviewjsmith92
 

Similar to static methods.pptx (20)

Inheritance
InheritanceInheritance
Inheritance
 
php.pdf
php.pdfphp.pdf
php.pdf
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
Complete list of all sap abap keywords
Complete list of all sap abap keywordsComplete list of all sap abap keywords
Complete list of all sap abap keywords
 
OOP is more than Cars and Dogs
OOP is more than Cars and Dogs OOP is more than Cars and Dogs
OOP is more than Cars and Dogs
 
MDE in Practice
MDE in PracticeMDE in Practice
MDE in Practice
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
 
Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,Global variables, sorting static variables,function and arrays,
Global variables, sorting static variables,function and arrays,
 
Intake 38 data access 3
Intake 38 data access 3Intake 38 data access 3
Intake 38 data access 3
 
Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1Objectorientedprogrammingmodel1
Objectorientedprogrammingmodel1
 
12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.ppt12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.ppt
 
Abap course chapter 7 abap objects and bsp
Abap course   chapter 7 abap objects and bspAbap course   chapter 7 abap objects and bsp
Abap course chapter 7 abap objects and bsp
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
 
Fundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptxFundamentals of Data Structures Unit 1.pptx
Fundamentals of Data Structures Unit 1.pptx
 
ABSTRACT CLASSES AND INTERFACES.ppt
ABSTRACT CLASSES AND INTERFACES.pptABSTRACT CLASSES AND INTERFACES.ppt
ABSTRACT CLASSES AND INTERFACES.ppt
 
Choose any multi-national organization that you would like to use .docx
Choose any multi-national organization that you would like to use .docxChoose any multi-national organization that you would like to use .docx
Choose any multi-national organization that you would like to use .docx
 
Analysis of software systems using jQAssistant and Neo4j
Analysis of software systems using jQAssistant and Neo4jAnalysis of software systems using jQAssistant and Neo4j
Analysis of software systems using jQAssistant and Neo4j
 
MOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX ApplicationsMOUG17: How to Build Multi-Client APEX Applications
MOUG17: How to Build Multi-Client APEX Applications
 
Php
PhpPhp
Php
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 

More from SanthiNivas

exception-handling-in-java.ppt
exception-handling-in-java.pptexception-handling-in-java.ppt
exception-handling-in-java.pptSanthiNivas
 
Introduction to PHP.ppt
Introduction to PHP.pptIntroduction to PHP.ppt
Introduction to PHP.pptSanthiNivas
 
transmission media.ppt
transmission media.ppttransmission media.ppt
transmission media.pptSanthiNivas
 
Internet Basics Presentation.pptx
Internet Basics Presentation.pptxInternet Basics Presentation.pptx
Internet Basics Presentation.pptxSanthiNivas
 
Features of Java.pptx
Features of Java.pptxFeatures of Java.pptx
Features of Java.pptxSanthiNivas
 
Output Devices.pptx
Output Devices.pptxOutput Devices.pptx
Output Devices.pptxSanthiNivas
 
Input Devices.pptx
Input Devices.pptxInput Devices.pptx
Input Devices.pptxSanthiNivas
 
Operating System File Management Unit v.pptx
Operating System File Management Unit v.pptxOperating System File Management Unit v.pptx
Operating System File Management Unit v.pptxSanthiNivas
 
Input and Output Devices
Input and Output DevicesInput and Output Devices
Input and Output DevicesSanthiNivas
 
DDA ALGORITHM.pdf
DDA ALGORITHM.pdfDDA ALGORITHM.pdf
DDA ALGORITHM.pdfSanthiNivas
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2SanthiNivas
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer GraphicsSanthiNivas
 
Page Layout and Background
Page Layout and BackgroundPage Layout and Background
Page Layout and BackgroundSanthiNivas
 
3-D Transformation in Computer Graphics
3-D Transformation in Computer Graphics3-D Transformation in Computer Graphics
3-D Transformation in Computer GraphicsSanthiNivas
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODSSanthiNivas
 
-Working with Text in Corel Draw
-Working with Text in Corel Draw-Working with Text in Corel Draw
-Working with Text in Corel DrawSanthiNivas
 

More from SanthiNivas (20)

packages.ppt
packages.pptpackages.ppt
packages.ppt
 
exception-handling-in-java.ppt
exception-handling-in-java.pptexception-handling-in-java.ppt
exception-handling-in-java.ppt
 
Introduction to PHP.ppt
Introduction to PHP.pptIntroduction to PHP.ppt
Introduction to PHP.ppt
 
Topologies.ppt
Topologies.pptTopologies.ppt
Topologies.ppt
 
transmission media.ppt
transmission media.ppttransmission media.ppt
transmission media.ppt
 
Internet Basics Presentation.pptx
Internet Basics Presentation.pptxInternet Basics Presentation.pptx
Internet Basics Presentation.pptx
 
Topologies.ppt
Topologies.pptTopologies.ppt
Topologies.ppt
 
Features of Java.pptx
Features of Java.pptxFeatures of Java.pptx
Features of Java.pptx
 
Output Devices.pptx
Output Devices.pptxOutput Devices.pptx
Output Devices.pptx
 
Input Devices.pptx
Input Devices.pptxInput Devices.pptx
Input Devices.pptx
 
Operating System File Management Unit v.pptx
Operating System File Management Unit v.pptxOperating System File Management Unit v.pptx
Operating System File Management Unit v.pptx
 
Input and Output Devices
Input and Output DevicesInput and Output Devices
Input and Output Devices
 
HTML
HTMLHTML
HTML
 
DDA ALGORITHM.pdf
DDA ALGORITHM.pdfDDA ALGORITHM.pdf
DDA ALGORITHM.pdf
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Computer Graphics
Computer GraphicsComputer Graphics
Computer Graphics
 
Page Layout and Background
Page Layout and BackgroundPage Layout and Background
Page Layout and Background
 
3-D Transformation in Computer Graphics
3-D Transformation in Computer Graphics3-D Transformation in Computer Graphics
3-D Transformation in Computer Graphics
 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODS
 
-Working with Text in Corel Draw
-Working with Text in Corel Draw-Working with Text in Corel Draw
-Working with Text in Corel Draw
 

Recently uploaded

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

static methods.pptx

  • 1. STATIC METHODS AND ABSTRACT CLASSES PREPARED BY V.SANTHI ASSISTANT PROFESSOR, DEPARTMENT OF COMPUTER APPLICATIONS, THANJAVUR
  • 2. STATIC METHODS: THE STATIC KEYWORD IS USED TO DECLARE PROPERTIES AND METHODS OF A CLASS AS STATIC. STATIC PROPERTIES AND METHODS CAN BE USED WITHOUT CREATING AN INSTANCE OF THE CLASS. THE STATIC KEYWORD IS ALSO USED TO DECLARE VARIABLES IN A FUNCTION WHICH KEEP THEIR VALUE AFTER THE FUNCTION HAS ENDED.
  • 3. PHP- STATIC METHODS: • STATIC METHODS CAN BE CALLED DIRECTLY - WITHOUT CREATING AN INSTANCE OF THE CLASS FIRST. • STATIC METHODS ARE DECLARED WITH THE STATIC KEYWORD:
  • 4. SYNTAX: • <?PHP CLASS CLASSNAME { PUBLIC STATIC FUNCTION STATICMETHOD() { ECHO "HELLO WORLD!"; } } ?>
  • 5. EXAMPLE: • <?PHP CLASS GREETING { PUBLIC STATIC FUNCTION WELCOME() { ECHO "HELLO WORLD!"; } } // CALL STATIC METHOD GREETING::WELCOME(); ?>
  • 6. OUTPUT: • HELLO WORLD! • EXAMPLE EXPLAINED • HERE, WE DECLARE A STATIC METHOD: WELCOME(). THEN, WE CALL THE STATIC METHOD BY USING THE CLASS NAME, DOUBLE COLON (:, AND THE METHOD NAME (WITHOUT CREATING AN INSTANCE OF THE CLASS FIRST).
  • 7. ABSTRACT CLASSES IN PHP: • ABSTRACT CLASSES AND METHODS ARE WHEN THE PARENT CLASS HAS A NAMED METHOD, BUT NEED ITS CHILD CLASS(ES) TO FILL OUT THE TASKS. • AN ABSTRACT CLASS IS A CLASS THAT CONTAINS AT LEAST ONE ABSTRACT METHOD. AN ABSTRACT METHOD IS A METHOD THAT IS DECLARED, BUT NOT IMPLEMENTED IN THE CODE.
  • 8. SYNTAX: • <?PHP ABSTRACT CLASS PARENTCLASS { ABSTRACT PUBLIC FUNCTION SOMEMETHOD1(); ABSTRACT PUBLIC FUNCTION SOMEMETHOD2($NAME, $COLOR); ABSTRACT PUBLIC FUNCTION SOMEMETHOD3() : STRING; } ?>
  • 9. EXAMPLE: • <?PHP // PARENT CLASS ABSTRACT CLASS CAR { PUBLIC $NAME; PUBLIC FUNCTION __CONSTRUCT($NAME) { $THIS->NAME = $NAME; } ABSTRACT PUBLIC FUNCTION INTRO() : STRING; }
  • 10. // CHILD CLASSES CLASS AUDI EXTENDS CAR { PUBLIC FUNCTION INTRO() : STRING { RETURN “CHOOSE GERMAN QUALITY! I’M AN $THIS->NAME!”; } } CLASS VOLVO EXTENDS CAR { PUBLIC FUNCTION INTRO() : STRING { RETURN “PROUD TO BE SWEDISH! I’M A $THIS->NAME!”; } }
  • 11. CLASS CITROEN EXTENDS CAR { PUBLIC FUNCTION INTRO() : STRING { RETURN "FRENCH EXTRAVAGANCE! I'M A $THIS->NAME!"; } } // CREATE OBJECTS FROM THE CHILD CLASSES $AUDI = NEW AUDI
  • 12. ECHO $AUDI->INTRO(); ECHO "<BR>"; $VOLVO = NEW VOLVO("VOLVO"); ECHO $VOLVO->INTRO(); ECHO "<BR>"; $CITROEN = NEW CITROEN("CITROEN"); ECHO $CITROEN->INTRO(); ?>
  • 13. RESULT: • CHOOSE GERMAN QUALITY! I'M AN AUDI! PROUD TO BE SWEDISH! I'M A VOLVO! FRENCH EXTRAVAGANCE! I'M A CITROEN!