JAVA Methods
01-07-2017    396 times
Actual formal parameter java method

What is Methods?

Methods or functions are the collection of statements in a group. It perform the specific goal as per requirement.

Methods are two types

  1. Build-in: These types of methods are pre written in the java development kit (JDK). Programmer can easily access these methods as per requirement.
  2. Users define: These types of methods are written by the programmer as per their requirement.
Tutorial at home

Explain function prototype of java?

The basic structure of a java method is called function prototype in java.

Function Prototype
Function Prototype

Part of the function prototype

  1. Access-specifier: This part of the function prototype is not mandatory. The value of the access-specifier will be
    1. default
    2. public
    3. private
    4. protected

If we don’t specifying any value, then the value will be default.

Tutorial at home
  1. Modifier: This part of the function prototype is also not mandatory. In general case we use the keyword static as a modifier. But we can use some other values like, final, abstract, synchronized and volatile.
  2. Return type: Any function of Java may or may not return a value. The data type of this value will be return type of the function. These types will be any primitive data type, reference type or void (if no value returns).
Note: function cannot return multiple values anyway.
  1. Function Name: This name will require when we try to invoke the function or method.
  2. Parameter: This is a list of parameters separated by comma (,). The types of the parameter will be a primitive data type or reference data type. This list is also known as function signature.
Tutorial at home
Tutorial at home

What is actual parameter and formal parameter?

When we call a method from another, then those parameters used to call the methods are known as actual parameter and those parameters used to hold the passing values are known as formal parameters.

Actual Parameter and Formal Parameter
Actual Parameter and Formal Parameter

Differentiate between call by value or pass by value and call by reference or pass by reference.[ICSE 2012]

Call by value means, a copy of the data item is passed to the method (Assume you pass a zerox copy of the note to your friend. If your Friend make any change on it then it will not reflect on your original copy). Generally variable of primitive data types are passes call by value.
Call by reference means a reference of the original data item is passed. No copy is made (Assume you pass your original note to your friend. If your Friend make any change on it then it will reflect on your original copy). Generally reference types are passed by reference.

softetechnologies
    Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
    Related Post
  Query About the post