[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

implimenting interface methods

Posted on 2006-11-23
7
Medium Priority
?
225 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:jaggernat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 140 total points
ID: 18004474
If you don't implement all of them, your class becomes abstract and you wont be able to create a complete instance
0
 
LVL 10

Author Comment

by:jaggernat
ID: 18004495
so do u think i should impliment all 5 methods?
0
 
LVL 12

Accepted Solution

by:
enachemc earned 260 total points
ID: 18004515
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:ADSLMark
ID: 18004522
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
 
LVL 10

Author Comment

by:jaggernat
ID: 18004533
>>>If you provide an empty implementation of a method, just throw an uncked exception (NotSupported, NotImplemented)

what is uncked exception?

thanks
0
 
LVL 12

Expert Comment

by:enachemc
ID: 18004575
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
 
LVL 10

Author Comment

by:jaggernat
ID: 18004590
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question