Answers for "methods declaration in java"

2

method declaration java

method declaration:
Access-modifers  Specifier  return-Type  MethodName(parameter){
		statements;
		}
 
Access-modifiers: public, protected, default, private
						public: visible to the world
 
Specifier: static, final, abstract, synchronized
					static: can be called through class name
 
return-types: void, any datatype
					void: does not return any value from the method
					datatype: return a value (MANDATORY)
 
 
static: can be called through class name
return methods: return-type is not void
it's mandatory to return value from the method
return statement: exits the current method 
 
can return value from a method, if return-type is not void
 
System.exit(0): exits the entire system
Posted by: Guest on May-28-2021
3

Methods in java

public class MethodExample
{
    public static void main(String args[])
    {
       printHi();
       int add = Addition(8, 3);
       System.out.println(add);
    }
    public static void printHi()
    {
       // This method has no return value
       System.out.println("Hi!");
    }
    public static int Addition(int a, int b)
    {
       // This method has a return value
       return a + b;
    }
}
Posted by: Guest on October-18-2021
2

method declaration java

method declaration:
Access-modifers  Specifier  return-Type  MethodName(parameter){
		statements;
		}
 
Access-modifiers: public, protected, default, private
						public: visible to the world
 
Specifier: static, final, abstract, synchronized
					static: can be called through class name
 
return-types: void, any datatype
					void: does not return any value from the method
					datatype: return a value (MANDATORY)
 
 
static: can be called through class name
return methods: return-type is not void
it's mandatory to return value from the method
return statement: exits the current method 
 
can return value from a method, if return-type is not void
 
System.exit(0): exits the entire system
Posted by: Guest on May-28-2021
3

Methods in java

public class MethodExample
{
    public static void main(String args[])
    {
       printHi();
       int add = Addition(8, 3);
       System.out.println(add);
    }
    public static void printHi()
    {
       // This method has no return value
       System.out.println("Hi!");
    }
    public static int Addition(int a, int b)
    {
       // This method has a return value
       return a + b;
    }
}
Posted by: Guest on October-18-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language