implimenting interface methods

hi experts

if i have  5 methods in an interface , in my implimentation class do i have to impliment all the 5 methods of that interface?
or can i impliment less than 5

thanks
J
LVL 10
jaggernatAsked:
Who is Participating?
 
enachemcConnect With a Mentor Commented:
yes, this is the point of interfaces. You must implement all methods. If you provide an empty implementation of a method, just throw an uncked exception (NotSupported, NotImplemented) ...
0
 
hoomanvConnect With a Mentor Commented:
If you don't implement all of them, your class becomes abstract and you wont be able to create a complete instance
0
 
jaggernatAuthor Commented:
so do u think i should impliment all 5 methods?
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
ADSLMarkCommented:
Yes, although for some java interfaces there are adapters, from which you can extend. These implement the interface in a default way. For example:

class WListener extends WindowsAdapter implements WindowListener

Now you can override only those methods that you want to implement.

Notice that this requires an adapter class. Other solution is as sketch by hoomanv.

Mark
0
 
jaggernatAuthor Commented:
>>>If you provide an empty implementation of a method, just throw an uncked exception (NotSupported, NotImplemented)

what is uncked exception?

thanks
0
 
enachemcCommented:
an exception that you do not have to declare that you throw and you are not obligated to catch.

http://www.javapractices.com/Topic129.cjp
0
 
jaggernatAuthor Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.