?
Solved

implimenting interface methods

Posted on 2006-11-23
7
Medium Priority
?
224 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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 …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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