File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interface and abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interface and abstract" Watch "Interface and abstract" New topic
Author

Interface and abstract

Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
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

Joined: Oct 12, 2000
Posts: 5093
"yes" on all counts.


42
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
hi wenting

please share your knowledge on the interface and abstract.
Raghu Shree
Ranch Hand

Joined: Mar 18, 2005
Posts: 143
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


Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="http://groups.yahoo.com/group/scjp_share" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="http://groups.yahoo.com/group/JavaBeat_SCWCD" target="_blank" rel="nofollow">SCWCD Group</a>
Parameswaran Thangavel
Ranch Hand

Joined: Mar 01, 2005
Posts: 485
Interface methods must not be static

i didn't get why it so? any explanation
vinuharan haran
Ranch Hand

Joined: Feb 26, 2005
Posts: 64
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....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Interface and abstract