C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

What is Method in java?

0 votes
96 views
asked by sunny Expert (11,410 points)

1 Answer

0 votes
Methods define actions that a class's objects (or instances) can do.
A method has a declaration part and a body.
The declaration part consists of a return value, the method name, and a list of arguments.
The body contains code that perform the action.
The return type of a method can be a primitive, an object, or void.
The return type void means that the method returns nothing.
The declaration part of a method is also called the signature of the method.
For example, here is the getSalary method that returns a double.

public class MainClass {

  double getSalary() {
    return 0.0;

  }
}
answered by augustaina Sr Member (4,820 points)

Related questions

0 votes
1 answer 53 views
0 votes
1 answer 81 views
81 views asked by smith Geek (15,340 points)
0 votes
1 answer 81 views
0 votes
1 answer 82 views
0 votes
1 answer 85 views
85 views asked by augustaina Sr Member (4,820 points)
...