Hello i have 3 questions:
1) Is it possible one class to heir from two other calasses?
2)Is it possible a constructor exist without parameters?
3)A constructor must return the class who construct?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hello i have 3 questions:
1) Is it possible one class to heir from two other calasses?
2)Is it possible a constructor exist without parameters?
3)A constructor must return the class who construct?
If you are asking about multiple inheritance (as found in, say, C++) the answer is no, and there are a number of reasons why multiple inheritance is not supported in Java
Aren't there any examples in your textbook or class notes or other material from which you are learning? Maybe even some explanations of what constructors are and what they do?
A constructor doesn't have a return data type and it doesn't return anything. Aren't there any examples in your textbook or class notes or other material from which you are learning? Maybe even some explanations of what constructors are and what they do?
Cheers!
Z
azizmaiden (March 2nd, 2013)
Regadring the interface view of multiple iheritance, you could use two or more interfaces, it will work.
Apart from that you can simulate multiple inheritance by declare and instaniate abstract classes in extending classes.
But that's all not the c++ way, unfornately .Refering the link: it occurs more than one time, I wish I have the power of C++ when I use java. But for me java is the best language anyway. Mainly because everything is on the heap
And to question 2:that's the standard constrcutor, every java class has it, except you declare another one
question 3: it's like the 'new' in C++, it's a special method it can only return a class instance
thank u very much for ur help yeah also i found the second one ;p u r very helpfull guys!