• Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt in interface  RSS feed

 
naga santhosh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
an interface can extend any number of classes simultaneously
or
an interface can implement any no of interfaces simultaneously
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you actually have a question?

I suggest you read the guidelines on How to ask questions here, because we're not in the business of doing your homework for you.

Winston
 
naga santhosh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didn't expect this reply from the forum. i am just a beginner in java and i want to learn thats it.
i did my home work and it created the confusion for me so i posted this query here . if the question is against the forum policy you can delete it
       -thankyou
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be pedantic, neither is actually exactly accurate. An interface doesn't extend any classes, nor does it implement anything (default methods aside) -- but given the two choices, if I had to choose, I would choose the latter.

BTW, what exactly are you trying to resolve?
Henry


PS... welcome to the ranch !!
 
Knute Snortum
Sheriff
Posts: 4274
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say, "a class can implement any number of interfaces."
 
Ganesh Patekar
Bartender
Posts: 726
23
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch again 
naga santhosh wrote:i did my home work and it created the confusion for me so i posted this query here

Can you post your code? If It has error(s) no problem also post complete error and let us know where you stuck.
Click here ---> UseCodeTags to post code only.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naga santhosh wrote:i didn't expect this reply from the forum. i am just a beginner in java and i want to learn thats it.

Folk around here tend to be quite literal. It's a hazard of the job.  Your original post didn't technically ask a question - it just posted two statement separated by an or. A question would have had "Which of these is correct?" or "Which is better" or something like that.

And what Winston was alluding to was that even if you had asked "which of these is correct?", to us, that looks like you are simply posting your homework question, putting in zero effort, and hoping someone answers it for you.  It would have been much better to have additionally included which YOU thought was correct and why, and then ask if you are right.
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naga santhosh wrote:an interface can extend any number of classes simultaneously
or
an interface can implement any no of interfaces simultaneously

Hopefully these two questions formulations do not appear in your homework paperwork as you presented them as both aren't correct though. And word simultaneously reads a bit strange in this context too.

1. Interfaces can extend (or not extend) other interface/-s only. Not much here can be added I think.

2. According to 1st point (above), interfaces in Java can extend interfaces, but not implement, even though since Java 8 you can have default method's implementation in interface, but this doesn't count as other interface implementation. So basically you can only use keyword extends when two or more interfaces are involved.
 
naga santhosh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually the thing is when i am learning INTERFACES vs EXTENDS  topic from online, some of the conclusions were drawn as follows
1) a class can extend only one class at a time 
2) a class can implement any number of interfaces simultaneously
3) both 1 and 2 are possible simultaneously
4) interface can extend any no of interfaces at a time

based on above conclusions following statements were thrown as INVALID
1) interfaces can implement any no' of classes simultaneously

2)an interface can extend any number of classes simultaneously.

3)class can implement any no of interfaces and can extend only one class at a time simultaneously.
             class A implements B, C ,D  extends E{  }
  
              so i didn't get the results when i compiled the programs on above results.
  but thanks finally i understood the concepts
 
Anton Golovin
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naga santhosh wrote:an interface can extend any number of classes simultaneously
or
an interface can implement any no of interfaces simultaneously


Hi, Naga.

Neither wording works. An interface can extend any number of interfaces at the same time.

With best regards,

Anton.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!