Welcome to Dream.In.Code
Become a Java Expert!

Join 149,515 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,363 people online right now. Registration is fast and FREE... Join Now!




Constructors, tru or false

 
Reply to this topicStart new topic

Constructors, tru or false, bit confused about some basic rules of constructors

mgoodsell
25 May, 2007 - 03:10 AM
Post #1

New D.I.C Head
*

Joined: 4 Apr, 2007
Posts: 2


My Contributions
OK, this I know is probably very simple, but i'd apprechiate the help.

Which of the following statements is NOT true?

Constructors can have parameters
Constructors can return a result
Constructors have the same name as the class they belong to
More than one constructor can be defined in a class

I'm guessing Constructors can return a result, I thought that maybe that you can have more than one constuctor defined is a class wasn't true too but apparently you can?...

Thanks guys.

Matt
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Constructors, Tru Or False
25 May, 2007 - 03:19 AM
Post #2

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,010



Thanked: 7 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
Constructors can't return a result. Do some reading HERE and HERE for more info on constructors.

This post has been edited by PennyBoki: 25 May, 2007 - 03:20 AM
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Constructors, Tru Or False
25 May, 2007 - 05:27 AM
Post #3

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
as long as the paramater list for each constructor is different, then yes you can have as many as you like, this allows you to instantiate a class with a lot of information or very little.

The constructor itself does not return anything, it is simply the code run when a class is instantiated (eg a copy is made). Nothing is "returned" the copy is simply applied to any variable you had it assigned to.
User is offlineProfile CardPM
+Quote Post

mgoodsell
RE: Constructors, Tru Or False
25 May, 2007 - 05:41 AM
Post #4

New D.I.C Head
*

Joined: 4 Apr, 2007
Posts: 2


My Contributions
QUOTE(William_Wilson @ 25 May, 2007 - 06:27 AM) *

as long as the paramater list for each constructor is different, then yes you can have as many as you like, this allows you to instantiate a class with a lot of information or very little.

The constructor itself does not return anything, it is simply the code run when a class is instantiated (eg a copy is made). Nothing is "returned" the copy is simply applied to any variable you had it assigned to.



Thanks guys, was what I thought, just wanted to be sure.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:04PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month