Solved

implimenting interface methods

Posted on 2006-11-23
7
220 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
7 Comments
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 35 total points
Comment Utility
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
Comment Utility
so do u think i should impliment all 5 methods?
0
 
LVL 12

Accepted Solution

by:
enachemc earned 65 total points
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 10

Expert Comment

by:ADSLMark
Comment Utility
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
Comment Utility
>>>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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresSpecial  challenge 13 40
factorial example challenge 10 59
maven java path setting 5 48
JDeveloper 12c for 32 bit 4 30
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 covers a step-by-step guide to install VisualVM launcher in eclipse.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now