In Java, Can an object have several different classes ?
If yes , how should Inheritance and Interface influence to it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not a very well-posed question. Any object can be of one and only one class (ignoring the non-object primitives like int.) On the other hand, a class may have an arbitrary number of superclasses, so your class can match the “is a” relationship of an artitrary number of other classes.
On the interface question, all an interface brings in is a “contract” — you’re making a promise to implement certain methods or have certain properties. This is somewhat similar to multiple inheritance but not really multiple inheritance. Again, implementing an interface means the class has another “is a” property, but it doesn’t mean it’s fully bringing in the other classes.