Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Constructors

  Asked By: Ella    Date: Jan 01    Category: Java    Views: 804
  

I have two queries.
1] Constructors do not have return type, but can we say that constructors
return object of the class to which they belong ? or Constructors do not
return any thing?

2] main method is void b'cause an applicaton does not return anything, Can
there be any situation
in which applicaton need to return something and what to that in that
situation.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Aaron Evans     Answered On: Jan 01

1) constructors  are not methods. They're just
constructors. They've the form of a method  without
return. They're invoked in automaticaly in class
instantiation, but can not be executed explicitly.

2) An application does not return  anything to the
system, buy you can return an exit code using the
method System.exit(int n) . Any n != 0 implies that
the exit was with errors.

 
Didn't find what you were looking for? Find more on Constructors Or get search suggestion and latest updates.




Tagged: