1Method is a collection of statements
2which returns a value upon its execution
3Method have a return and the method's name may or not be same as the class
4name.
5Method is invoked explicitly.
6Method is not provided by compiler in any case.
7Methods are inherited by child classes.
1Method is a collection of statements
2which returns a value upon its execution.
3 Method have a return and the method's name may or not be same as the class
4name.
5Method is invoked explicitly.
6Method is not provided by compiler in any case.
7Methods are inherited by child classes.
1Static methods: A static method is a method that can be called and executed without creating an object
2Instance methods: These methods act upon the instance variables of a class
3Factory methods: A factory method is a method that returns an object to the class to which it belong
1method declaration:
2Access-modifers Specifier return-Type MethodName(parameter){
3 statements;
4 }
5
6Access-modifiers: public, protected, default, private
7 public: visible to the world
8
9Specifier: static, final, abstract, synchronized
10 static: can be called through class name
11
12return-types: void, any datatype
13 void: does not return any value from the method
14 datatype: return a value (MANDATORY)
15
16
17static: can be called through class name
18return methods: return-type is not void
19it's mandatory to return value from the method
20return statement: exits the current method
21
22can return value from a method, if return-type is not void
23
24System.exit(0): exits the entire system
25