Keywords, Methods, Objects, Void, Return type & Variables…

=====>> [TBD]
_Method have two types. They are,

  1. Method Overloading
  2. Method Overriding_

Keywords:

Static:
Static refers to class specific information.
Class have common for all objects.
only one memory copy.

Non-static:
Non-static refers to object specific information.
object have specific information.
Multiple memory copy.

Method:

Method is a set of instruction with a name to perform specific task.
Method has return type.

Example:

String buy()
{
System.out.println("buy method");
}

Object:

Object is a combination of state and behaviour.

Syntax for creating a object:

Home person = new Home();

new – is a keyword creating a new space to new object.
Home – is a class name
person – represents object name

Void:

Void is a return type of the method.
Not return anything and doing something inside the method.

Return type:

Return is a keyword is used to return any value from a method.
Return value will be sent back to method calling statement.
In return value void should not be used because return datatype should be used for storing value.
Return statement should be the last statement in a method definition.

Example:

String buy()
{
System.out.println("buy method");
return "thank you"
}

Local and Global variables:

Local variables are used inside the method.
Global variables are used outside the method.

Similar Posts