Java4teachus

Saturday, July 28, 2018

Development Of Methods in Java

Development of Methods

In previous post  we are already discuss about on the DataTypes in java. Now we are learning the Methods concept.

In Computer programming a function prototype or function interface can be declaration of a function that specifies the functions name and type of signature  (Datatype of parameter and return type), It is called as function body. A function prototype mostly specifies its interface, i.e what data types go in and come out of it. The terms function prototype is particularly used in the context of the programming language c and c++.

In any programming languages like to perform  if any type of operations, Then we must have learn the " Function " concept . Function is one of the concept in C Language, But in Java functions is also called as "Methods" . 


Development-of-methods-in-java.jpeg

A method is in Object-Oriented programming called as OOPS is a procedure associated with a message and object. An object is mostly have  data and behavior, Where is formed from the interface that an object present to the outside world. Data is represented as the properties of the object and behavior as methods.

Example:- window is an object would have methods such as open and close.

class Window
{
................
void open
{
................
}
void close
{
................
}

}

➤In Java programming language, Methods are defined in a class amd objects are instance of a given class.

➤It is one of the most important capabilities that have methods provides the method overriding. The same name Area can be used for multiple time with different kinds of  classes.
➤In Java programming, A method have a set of behavior in a class object.
For Example:-  An Object can send an area message to another object and the appropriate formula when receive the object is a rectangle, circle, triangle etc.. .
Syntax :-
void main( )
{
      ....... 
 ( Business logic / Execution logic )
      .......
 }

Definition Of Method

A method is a set of code which is referred by name and it can called as invoked at any point in a program which is simply by utilizing the methods name (or)  A self contained block of statements is a called a "Methods".  (or) A  part of the main program is called a "Methods".

Advantages Of Methods

  • Application development is less.
  • Application takes less memory.
  • Redundancy of the code is minimized.
  • We are able slogan of the method "write code once call any where".

Part Of The Methods

 At during the time of the methods we must ensure that 3 parts . They are :
  1. Method definition 
  2. Method declaration
  3. Method call

Phases Of The Method  

At the time of defining the methods then we must ensure 3 phases. They are :
  1. Method is taking input 
  2. Method is doing process
  3. method is giving input

Number Of Approaches To Define Methods

 At the time of defines the methods then we must following the 4 approaches. They are :
  1. A Method is taking input & Returning values.
  2. A Methods is non taking input & Non Returning values.
  3. A  Method is taking input & Non Taking values .
  4. A method is non taking input & Returning values.

No comments:

Post a Comment

Thanks for visiting my site..