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
89 views
asked May 10, 2014 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 May 10, 2014 by augustaina Sr Member (4,820 points)

Related questions

0 votes
1 answer 51 views
51 views asked Jan 9, 2014 by sara Guru (24,570 points)
0 votes
1 answer 75 views
75 views asked May 10, 2014 by smith Geek (15,340 points)
0 votes
1 answer 76 views
0 votes
1 answer 77 views
77 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
0 votes
1 answer 80 views
80 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
...