hey! i m reading java. and at one place i have read Audio interface in which play(), loop() functions are defined,but interface is something in which there can't be any method defined. so this must be abstract not interface.so please tell this problem, y we are calling this as interface. AudioClip interface, i am talking about!! i m have read it's API also, but here also it is defined as interface but at there only, play() like methods are defined in it. how is it possible?
gourav1
-12
Posting Whiz in Training
Recommended Answers
Jump to PostAn interface is an agreement that a class with conform to certain things -- like having certain methods.
That way, the calling mechanism can be guaranteed it can call the play() method on your class if it is from the AudioClip interface.
Jump to Posttake a look at this
in an interface, you can declare methods, you just don't give them a 'body'.
which means:
public void play();
is allowed
Jump to PostThere are many formats for sounds to play, and many possible sources to play them from. There are classes to play various formats from various sources, all different classes. But they all implement the same interface, so they all support the same calls to their play methods.
This means that …
Jump to Postalso, you're not necessarily 'calling' the interface.
for instance:public interface IntA{ public void run(); } public class ClaB{ public ClaB(){ } public void run(){ } }
if you have something like this, you can, for example, code:
public static void main(String[] args){ IntA …
Jump to Postyou don't 'inherit' an interface, you implement it.
inheriting means you don't have to write the code, there's a complete functional method, including body and logic in the class you're inheriting. you only need to write the method yourself if you would like to adjust the logic therein.
implementing an …
All 21 Replies
thines01
401
Postaholic
Team Colleague
Featured Poster
gourav1
-12
Posting Whiz in Training
stultuske
1,116
Posting Maven
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
gourav1
-12
Posting Whiz in Training
stultuske
1,116
Posting Maven
Featured Poster
gourav1
-12
Posting Whiz in Training
stultuske
1,116
Posting Maven
Featured Poster
gourav1
-12
Posting Whiz in Training
stultuske
1,116
Posting Maven
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
gourav1
-12
Posting Whiz in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
thines01
401
Postaholic
Team Colleague
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
thines01
401
Postaholic
Team Colleague
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
thines01
401
Postaholic
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.