-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7. java methods.txt
More file actions
27 lines (24 loc) · 1.28 KB
/
7. java methods.txt
File metadata and controls
27 lines (24 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
methods are the codeblocks which helps us to perform some task by introducing code reusability and modularity
how a method is declared in java:
access specifier
static/non-static
return type
methodName
parameters
method Body
types of methods in java:
system defined methods: defined in the built in libraries of java
user defined methods: defined by the user
overloaded methods: methods which are overloaded
overriden methods: methods which are overriden
static methods: they belong to the class and not to the objects of the class and they can be called without
creating the object of the class. They cannot access the instance states and methods directly
final methods: these cannot be overriden by the subclasses and these methods ensures that the behaviour remains unchanged in the subclass also
abstract methods: methods which are declared without an implementation and must be implemented by subclasses
and they are defined in the abstract classes
varargs in java:
-they have been introduced in java 5
-they allow to pass zero or more arguments of the same type in the method
-only one varargs parameter is allowed per method
-the varargs parameter should be the last parameter in the parameter's list of the function
-inside the method, the varargs parameter is treated as an array