OOP IN JAVA (PARAMETERS AND ARGUMENT/ CONSTRUCTOR)


 Parameters and Argument 

The values that are declared within a function when the function is called are known as an argument. Whereas the variables that are defined when the function is declared are known as a parameter.


When a function is called, the values that are passed in the call are called arguments. While the variables that are written at the time of the function prototype and the definition of the function are called java parameters.

Java arguments are used in the function call statement to send values from the calling function to the called function while Java parameters are used in the function header of the called function to receive the value from the arguments.

During the time of call, each argument is always assigned to the parameter in the function definition. While parameters are local variables that are assigned a value of the arguments when the function is called.

Java arguments are also known as actual parameters. While the parameters are also known as formal parameters

when you add data type for the return type add RETURN Key word,








Constructor method 

Java constructors or constructors in Java is a terminology used to construct something in our programs. A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes. 



Constructor Calling

  1. The constructor should be created with the name of the class.
  2. There is no return type.


Finally,

  • When the application is run, the constructor is run first.
  • When the program starts to run, the work that needs to be done is coded inside the constructor.
  • Even if there is no return type, the constructor can pass the value and use the parameter argument.







Comments

Popular posts from this blog

DEMYSTIFYING THE POWER OF x86 ARCHITECTURE

A GUID TO BEACOMING A SOFTWARE ENGINEER

JAVA LAMBDA EXPRESSION