search
Login

Categories


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

3.8k questions

4k answers

117 comments

10.7k users

0 votes
104 views
asked Expert 11.4k points 14 22 28

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 Sr Member 4.8k points 10 25 31

Related questions

0 votes
1 answer 57 views
57 views
asked sara Guru 24.6k points 29 52 81
0 votes
1 answer 88 views
88 views
asked smith Geek 15.3k points 16 41 63
0 votes
1 answer 88 views
0 votes
1 answer 89 views
89 views
asked augustaina Sr Member 4.8k points 10 25 31
0 votes
1 answer 92 views
92 views
asked augustaina Sr Member 4.8k points 10 25 31
...