concept return type in category java

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide MEAP V03.
Option (e) is incorrect. It isn’t a valid method definition because it doesn’t specify the return type of the method. This line of code will not compile.
Figure 8.2 shows the code of a method accepting method parameters and defining a return type and a return statement.
Figure 8.2 An example of a method that accepts method parameters and defines a return type and a return statement
![]()
Let’s get started with a discussion of the return type of a method.
The return type of a method specifies the type of value that a method will return. A method may or may not return a value. One that doesn’t return a value has a return type of void. A method can return a primitive value or an instance of any class. The return type can be any of the eight primitive types defined in Java, a class, or an interface. A method can also return an enum value, or an instance of inner class (however, these are not covered in this book since they are out of scope of the exam).
Revisit the use and declaration of the previously mentioned constructors. Note that a constructor is called when you create an instance of a class. A constructor does have an implicit return type, which is the class in which it’s defined. It creates and returns an instance of its class, which is why you can’t define a return type for a constructor. Also note that you can define constructors using any of the four access levels.
Exam Tip You can define a constructor using all four access levels: public, protected, default, and private.
What happens if you define a return type for a constructor? Java will treat it as another method, not a constructor, which also implies that it won’t be called implicitly when you create an instance of its class:
class Employee { void Employee() { System.out.println("Constructor"); } } class Office { public static void main(String args[]) { Employee emp = new Employee(); #1 } }In the preceding example, #1 won’t call the method Employee, which defines its return type as void. A method that has the same name as its class, but defines a return type (void, or any other data type), it’s no longer treated as a constructor.
If the class Employee defines the return type of the method Employee as void, how can Java use it to create an instance? The method (with the return type void) is treated as any other method in the class Employee. This logic applies to all the other data types: if you define the return type of a constructor to be any data type—such as char, int, String, long, double, or any other class—it’ll no longer be treated as a constructor.