Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on Interface

 
Rahul Sud
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Last weekend one of my colleague faced the interview.Interviewer asked him Interface Vs abstract Interface.
He knows Interface he defined it well but for abstract Interface he replied same like interface but keyword abstract is used and it is redundant because interface is also abstract.But here we are explicitly write abstract for abstract Interface.

Interviewer was not happy with the answer.

I am also thinking what can be the best answer.Also same like interface but keyword abstract is used.

Like say:

Please throw some light on this abstract Interface.



Thank You!

Regards,
Rahul
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4512
275
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Java, there is no use of specifying "abstract" keyword for an interface - all of the Java interfaces are implicitly abstract.
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every method in an interface is public and abstract, and every field in an interface is public, static and final. If you leave out any of these words that doesn't change a thing -- they are still regarded to be there.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49447
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you told an interviewer there is a difference between an interface and an abstract interface, you wouldn't expect to get the job. You sure it wasn't "abstract class"?
 
Rahul Sud
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all....

This question was asked to my colleague in a interview.His expression was there with awkward sound abstract interface....Then he thinks to better answer it and he answered as same like interface but keyword abstract is used and it is redundant because interface is also abstract.

After weekend my colleague also discussed the same with me.I was also surprised because i never came across such abstract interface term.....


Any way yeah it make sense now after discussion with you guys
 
Campbell Ritchie
Sheriff
Pie
Posts: 49447
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic