SlideShare a Scribd company logo
Methods in java
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
Introduction
 the method in Java is a collection of instructions that
performs a specific task.
 It provides the reusability of code. We can also easily
modify code using methods.
 A method is a block of code or collection of
statements or a set of code grouped together to
perform a certain task or operation.

Cont..
 It is used to achieve the reusability of code.
 We write a method once and use it many times. We do
not require to write code again and again.
Method Declaration
Types of Method
 There are two types of methods in Java:
 Predefined Method
 User-defined Method
Predefined Method
 In Java, predefined methods are the method that is already
defined in the Java class libraries is known as predefined
methods.
 It is also known as the standard library method or built-
in method.
 We can directly use these methods just by calling them in
the program at any point.
 Some pre-defined methods are length(), equals(),
compareTo(), sqrt(), etc.
Example
 public class Demo
 {
 public static void main(String[] args)
 {
 // using the max() method of Math class
 System.out.print("The maximum number is: " + Math.
max(9,7));
 }
 }
User-defined Method
 The method written by the user or programmer is
known as a user-defined method.
 These methods are modified according to the
requirement.
Example
 public static void findEvenOdd(int num)
 {
 //method body
 if(num%2==0)
 System.out.println(num+" is even");
 else
 System.out.println(num+" is odd");
 }
Assignment
 Explain Methods in java and their types with suitable
example.
Ad

More Related Content

What's hot (20)

Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
kunal kishore
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 
Java packages
Java packagesJava packages
Java packages
BHUVIJAYAVELU
 
Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
Madishetty Prathibha
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
Arzath Areeff
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
Operators in java
Operators in javaOperators in java
Operators in java
AbhishekMondal42
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
Madishetty Prathibha
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Lovely Professional University
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
VINOTH R
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
jaimefrozr
 

Similar to Methods in java (20)

Functions & Methods in Java: A Beginner's Guide.pptx
Functions & Methods in Java: A Beginner's Guide.pptxFunctions & Methods in Java: A Beginner's Guide.pptx
Functions & Methods in Java: A Beginner's Guide.pptx
Chris Lewis
 
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptxModule 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
rishiskj
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
Sugavanam Natarajan
 
The Java Learning Kit Chapter 5 – Methods and Modular.docx
The Java Learning Kit Chapter 5 – Methods and Modular.docxThe Java Learning Kit Chapter 5 – Methods and Modular.docx
The Java Learning Kit Chapter 5 – Methods and Modular.docx
arnoldmeredith47041
 
UNIT1-JAVA.pptx
UNIT1-JAVA.pptxUNIT1-JAVA.pptx
UNIT1-JAVA.pptx
ssuser99ca78
 
Method overloading and method overriding
Method overloading and method overridingMethod overloading and method overriding
Method overloading and method overriding
RomitRajSingh1
 
Web Technology-Method .pdf
Web Technology-Method                .pdfWeb Technology-Method                .pdf
Web Technology-Method .pdf
nandiaditi2010
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdet
DevLabs Alliance
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDET
DevLabs Alliance
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdet
devlabsalliance
 
Object Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for studentsObject Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for students
ASHASITTeaching
 
Week 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdfWeek 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdf
JaypeeGPolancos
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
nofakeNews
 
Learn To Code: Diving deep into java
Learn To Code: Diving deep into javaLearn To Code: Diving deep into java
Learn To Code: Diving deep into java
SadhanaParameswaran
 
PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,
shubhamkumar248717
 
Core Java Interview Questions PDF By ScholarHat
Core Java Interview Questions PDF By ScholarHatCore Java Interview Questions PDF By ScholarHat
Core Java Interview Questions PDF By ScholarHat
Scholarhat
 
Abstraction encapsulation inheritance polymorphism
Abstraction encapsulation inheritance polymorphismAbstraction encapsulation inheritance polymorphism
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1
Sherihan Anver
 
Viva file
Viva fileViva file
Viva file
anupamasingh87
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
Rich Helton
 
Functions & Methods in Java: A Beginner's Guide.pptx
Functions & Methods in Java: A Beginner's Guide.pptxFunctions & Methods in Java: A Beginner's Guide.pptx
Functions & Methods in Java: A Beginner's Guide.pptx
Chris Lewis
 
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptxModule 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
Module 1 full slidfcccccccccccccccccccccccccccccccccccdes.pptx
rishiskj
 
The Java Learning Kit Chapter 5 – Methods and Modular.docx
The Java Learning Kit Chapter 5 – Methods and Modular.docxThe Java Learning Kit Chapter 5 – Methods and Modular.docx
The Java Learning Kit Chapter 5 – Methods and Modular.docx
arnoldmeredith47041
 
Method overloading and method overriding
Method overloading and method overridingMethod overloading and method overriding
Method overloading and method overriding
RomitRajSingh1
 
Web Technology-Method .pdf
Web Technology-Method                .pdfWeb Technology-Method                .pdf
Web Technology-Method .pdf
nandiaditi2010
 
Dev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdetDev labs alliance top 20 basic java interview questions for sdet
Dev labs alliance top 20 basic java interview questions for sdet
DevLabs Alliance
 
Top 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDETTop 20 basic java interview questions for SDET
Top 20 basic java interview questions for SDET
DevLabs Alliance
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdet
devlabsalliance
 
Object Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for studentsObject Oriented Programming unit 1 content for students
Object Oriented Programming unit 1 content for students
ASHASITTeaching
 
Week 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdfWeek 7 Java Programming Methods For I.T students.pdf
Week 7 Java Programming Methods For I.T students.pdf
JaypeeGPolancos
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
nofakeNews
 
Learn To Code: Diving deep into java
Learn To Code: Diving deep into javaLearn To Code: Diving deep into java
Learn To Code: Diving deep into java
SadhanaParameswaran
 
PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,
shubhamkumar248717
 
Core Java Interview Questions PDF By ScholarHat
Core Java Interview Questions PDF By ScholarHatCore Java Interview Questions PDF By ScholarHat
Core Java Interview Questions PDF By ScholarHat
Scholarhat
 
Abstraction encapsulation inheritance polymorphism
Abstraction encapsulation inheritance polymorphismAbstraction encapsulation inheritance polymorphism
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
Java interview questions 1
Java interview questions 1Java interview questions 1
Java interview questions 1
Sherihan Anver
 
Java for Mainframers
Java for MainframersJava for Mainframers
Java for Mainframers
Rich Helton
 
Ad

More from chauhankapil (20)

Gray level transformation
Gray level transformationGray level transformation
Gray level transformation
chauhankapil
 
Elements of visual perception
Elements of visual perceptionElements of visual perception
Elements of visual perception
chauhankapil
 
JSP Client Request
JSP Client RequestJSP Client Request
JSP Client Request
chauhankapil
 
Jsp server response
Jsp   server responseJsp   server response
Jsp server response
chauhankapil
 
Markov decision process
Markov decision processMarkov decision process
Markov decision process
chauhankapil
 
RNN basics in deep learning
RNN basics in deep learningRNN basics in deep learning
RNN basics in deep learning
chauhankapil
 
Introduction to generative adversarial networks (GANs)
Introduction to generative adversarial networks (GANs)Introduction to generative adversarial networks (GANs)
Introduction to generative adversarial networks (GANs)
chauhankapil
 
Bayesian probabilistic interference
Bayesian probabilistic interferenceBayesian probabilistic interference
Bayesian probabilistic interference
chauhankapil
 
Jsp
JspJsp
Jsp
chauhankapil
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
chauhankapil
 
Knowledge acquistion
Knowledge acquistionKnowledge acquistion
Knowledge acquistion
chauhankapil
 
Knowledge based system
Knowledge based systemKnowledge based system
Knowledge based system
chauhankapil
 
Introduction of predicate logics
Introduction of predicate  logicsIntroduction of predicate  logics
Introduction of predicate logics
chauhankapil
 
Types of inheritance in java
Types of inheritance in javaTypes of inheritance in java
Types of inheritance in java
chauhankapil
 
Representation of syntax, semantics and Predicate logics
Representation of syntax, semantics and Predicate logicsRepresentation of syntax, semantics and Predicate logics
Representation of syntax, semantics and Predicate logics
chauhankapil
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
chauhankapil
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
chauhankapil
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
chauhankapil
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
chauhankapil
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
chauhankapil
 
Gray level transformation
Gray level transformationGray level transformation
Gray level transformation
chauhankapil
 
Elements of visual perception
Elements of visual perceptionElements of visual perception
Elements of visual perception
chauhankapil
 
JSP Client Request
JSP Client RequestJSP Client Request
JSP Client Request
chauhankapil
 
Jsp server response
Jsp   server responseJsp   server response
Jsp server response
chauhankapil
 
Markov decision process
Markov decision processMarkov decision process
Markov decision process
chauhankapil
 
RNN basics in deep learning
RNN basics in deep learningRNN basics in deep learning
RNN basics in deep learning
chauhankapil
 
Introduction to generative adversarial networks (GANs)
Introduction to generative adversarial networks (GANs)Introduction to generative adversarial networks (GANs)
Introduction to generative adversarial networks (GANs)
chauhankapil
 
Bayesian probabilistic interference
Bayesian probabilistic interferenceBayesian probabilistic interference
Bayesian probabilistic interference
chauhankapil
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
chauhankapil
 
Knowledge acquistion
Knowledge acquistionKnowledge acquistion
Knowledge acquistion
chauhankapil
 
Knowledge based system
Knowledge based systemKnowledge based system
Knowledge based system
chauhankapil
 
Introduction of predicate logics
Introduction of predicate  logicsIntroduction of predicate  logics
Introduction of predicate logics
chauhankapil
 
Types of inheritance in java
Types of inheritance in javaTypes of inheritance in java
Types of inheritance in java
chauhankapil
 
Representation of syntax, semantics and Predicate logics
Representation of syntax, semantics and Predicate logicsRepresentation of syntax, semantics and Predicate logics
Representation of syntax, semantics and Predicate logics
chauhankapil
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
chauhankapil
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
chauhankapil
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
chauhankapil
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
chauhankapil
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
chauhankapil
 
Ad

Recently uploaded (20)

Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
π0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalizationπ0.5: a Vision-Language-Action Model with Open-World Generalization
π0.5: a Vision-Language-Action Model with Open-World Generalization
NABLAS株式会社
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
theory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptxtheory-slides-for react for beginners.pptx
theory-slides-for react for beginners.pptx
sanchezvanessa7896
 
AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)AI-assisted Software Testing (3-hours tutorial)
AI-assisted Software Testing (3-hours tutorial)
Vəhid Gəruslu
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 

Methods in java

  • 1. Methods in java Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2. Introduction  the method in Java is a collection of instructions that performs a specific task.  It provides the reusability of code. We can also easily modify code using methods.  A method is a block of code or collection of statements or a set of code grouped together to perform a certain task or operation. 
  • 3. Cont..  It is used to achieve the reusability of code.  We write a method once and use it many times. We do not require to write code again and again.
  • 5. Types of Method  There are two types of methods in Java:  Predefined Method  User-defined Method
  • 6. Predefined Method  In Java, predefined methods are the method that is already defined in the Java class libraries is known as predefined methods.  It is also known as the standard library method or built- in method.  We can directly use these methods just by calling them in the program at any point.  Some pre-defined methods are length(), equals(), compareTo(), sqrt(), etc.
  • 7. Example  public class Demo  {  public static void main(String[] args)  {  // using the max() method of Math class  System.out.print("The maximum number is: " + Math. max(9,7));  }  }
  • 8. User-defined Method  The method written by the user or programmer is known as a user-defined method.  These methods are modified according to the requirement.
  • 9. Example  public static void findEvenOdd(int num)  {  //method body  if(num%2==0)  System.out.println(num+" is even");  else  System.out.println(num+" is odd");  }
  • 10. Assignment  Explain Methods in java and their types with suitable example.