This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface and abstract

 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
for interface:

while implementing interface we need to take care
1)the implemented method shuld be public.since by default the interface are public and final.shall we able to mention it explicitly.
2)can the methods be overloaded or overridden

Absract:

1)similar to that is there any rule that we need to take care while extending the abstract.what is the access modifier for the method in the abstract(by default).
2)can the methods be overloaded or overridden

please share ur knowledge in these topics.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"yes" on all counts.
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi wenting

please share your knowledge on the interface and abstract.
 
Raghu Shree
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interface & Abstract

==>Abstract class can define both abstract and non abstratc methods, an ==>interface can have only abstract methods.
==>Interface methods must not be static
==>Interface can declare only constants not instance variables.
==>Interace variables are cannot be either protected or Transient.
==>Interface methods are cannot be static or final
==>Abstract classes are cannot be marked as final
==>Abstract classes are cannot be instantiated
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interface methods must not be static

i didn't get why it so? any explanation
 
vinuharan haran
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Interface methods are public and abstract(not final) by default.u can also declare it explicitly.Even the interface can be declared abstract.
2.overriding and overloading is possible.
abstract class
1.The abstract methods should not be declared private.It can have public,protected and default access.
2.The abstract methods can be overridden and overloaded.
Hope this helps....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic