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?
Printable View
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
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 :D yeah also i found the second one ;p u r very helpfull guys!