|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

04-03-2008, 12:27 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
help
one class can implement multiple interfaces but it can't extend two calsses why??????
Last edited by Sayed : 04-03-2008 at 12:32 PM.
|
|

04-03-2008, 12:34 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
Multiple inheritance, means one class directly can't extend two classes.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-03-2008, 12:41 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
i want the exact reason for that??..what will be the problem if one class extends multiple calsses directly...one class can implement multiple interfaces directly right...
|
|

04-03-2008, 12:53 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
That is because to avoid dangers like ambiguity that is present in C++, you may know.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-03-2008, 01:00 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
Thanks for your respone ......could you please brief me on that????what danger it is????
|
|

04-03-2008, 01:09 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
Oh dear, say ClassA extend from ClassB and ClassC. Say ClassB has a method sampleMethod() and ClassC has sampleMethod(), which method ClassA should call. Compiler really mess-up with it.
That's why SUNs' avoid this. So you can simply use interfaces. As I said there is a trick for multiple inheritance also.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-03-2008, 01:19 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
Thanks yaar...Thanks a lot for your help...
|
|

04-03-2008, 01:21 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
Is that clear for you. If the question is solved don't forget what I say 
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-03-2008, 01:28 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
But what about interfaces???if two interfaces contains same method compiler won't mess-up...
|
|

04-03-2008, 01:37 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
Did you try it?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-03-2008, 01:57 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
yes i tried it...it is not showing any compilation problem but the actual implemented method is not executing...could u please help me on this....
|
|

04-03-2008, 01:59 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
What you mean actual implemented method is not executing. I'm not clear with it. Do you have any code with you.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-03-2008, 02:13 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
Sorry Its executing it is not showing any problems.
|
|

04-03-2008, 02:14 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,405
|
|
|
Ok, so you overloading methods, right?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|
|

04-03-2008, 02:16 PM
|
|
Member
|
|
Join Date: Jan 2008
Posts: 11
|
|
|
Please have a look on this code:
public class Test implements Sample1,Sample2{
public static void main(String args[]){
System.out.println("public static void main");
Test t=new Test();
t.jen();
}
public void jen() {
System.out.println("Success");
}
}
Interface 1:
ublic interface Sample1 {
public void jen();
}
Interface:2
public interface Sample2 {
public void jen();
}
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|