[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Regarding interfaces and abstract class in java

Posted on 2006-06-10
27
Medium Priority
?
300 Views
Last Modified: 2010-03-31

In Java,  interfaces provide empty methods which has to be overrided when implemented. So instead of implementing those interfaces, if we directly define those methods in our class, wont it work? Then why r interfaces used? And how is it different from abstract class. On what contexts are both used?
0
Comment
Question by:shaan432
[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
  • 8
  • 5
  • 5
  • +5
27 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 16877073
No, an interface is just a promise to implement.
An interface becomes an identity that gives a class a characteristic.

An abstract class is ...................... a class!
It's a building block.

;JOOP!
0
 
LVL 24

Accepted Solution

by:
sciuriware earned 128 total points
ID: 16877083
Very important: given an interface  Abortable  promising a method  void abort() to stop any actions.

You can have 2 completely different classes A & B implementing them.

Declare    Abortable q = .....

Later:      q.abort();  // What will stop? You don't care if it's an A or B

'q' "sees" only the ability to call 'abort()' without asking "what kind of class is this".


An abstract class has nothing to do with this.
It is a begin to build a full blown class but the extend depend on your needs.
Good example: List;   see all classes derived from it.

;JOOP!

0
 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 124 total points
ID: 16877124
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 124 total points
ID: 16878605
basically it all for a concrete design! and provides a high level of abstraction.

for e.g.,

interface Connection{
  void connect(...);
  void sendData(...);
  Object recieveData();
}

class abstract AbstractConnection implements Connection{
  public Object encodeData(...){
    // encode impl
  }

  public Object decodeData(...){
    //decode impl
  }
}

class HTTPConnection implements Connection{
  // all connection impl
}

class SecureHTTPConnection extends AbstractConnection{
  // all impl
}

interface declares methods for set of classes
abstraact class provides some common functionalit for set of classes

Also here based on the user previlleage you can give permission for accessing functionalities. For e.g., if a user has previllege for only the Connection interface, he can access method declared only in the interface...
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16879743
ksivananth, must you interfere everywhere?
Find a question to be answered.

;JOOP!
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 16879914
I just wanted to explain it in simple terms, after all its a forum and anybody can post their ideas for the context! Ultimately the person has to understand and get the ideas, don't worry, nothing going to affect u :)
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16879927
Then wait for his/her response, don't bomb with info.
The person must have a chance to learn.
Apart from that, you are always welcome with new or different insights.

;JOOP!
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 16880003
I don't know what makes u think that and how he lost the chance for learning, its upto the person who reads the posting, He is going to take whatever info he needs.

BTW, it is not a place to shout at one. if u have info just post it and correct other posting if its really wrong. Dont bring unncessary rules!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16880017
Most confusing to others.
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 16880047
tell me what my posting confused u!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16880140
this kind of unnecessary discussions in the greed for points, #55.
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 16880161
I think, if u are not greedy, the junk wouldn't be...

Ok buddy, u take the points, I don't need a single point. If u told me that all at the first that your concern is points, I wouldn't have replied
0
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 124 total points
ID: 16880189
0
 
LVL 8

Expert Comment

by:colr__
ID: 16883726
>> must you interfere everywhere?

I know you didnt ask for it, but in my opinion, this is outrageous bahaviour. This is a FORUM, a public post/debate site. EE is being littered recently with bitchiness between experts who are supposed to have the same goal - helping others. EE also plainly state in their question-post form that "experts compete for points" so it isnt a question of being greedy - for most experts, myself included, this is the whole point.

I think EE is the best forum I've used on the 'net, but it does have a problem with bickering between experts.

I also believe that the more people respond to a question, even if they all say the same thing, the better it is - when Im trying to elarn something I appreciate having multiple sources to read, so I can cross reference them and get different viewpoints.

And sciuriware, I really hope your response doesnt start with "yes, we didint ask your opinion..." - it's too predictable.

colr__
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16883876
You may be right colr__ but I am not the only one suffering from comments being repeated.
You can see constructive comments above.

There is a fine line between adding info and jacking.
In this case I was probably a bit too much irritated.

Sorry ksivananth; and thanks colr__.

;joop!
0
 
LVL 8

Expert Comment

by:colr__
ID: 16883917
Good will to all (wo)men!!! ;-)
0
 
LVL 92

Expert Comment

by:objects
ID: 16883979
> You may be right colr__ but I am not the only one suffering from comments being repeated.

get used to it :)
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 16883990
Yes objects, you could know: you have been around FOR SIX YEARS!
You must be one of the oldest members.

And I'll take your advise.

;JOOP!
0
 

Author Comment

by:shaan432
ID: 16930327
pls dont fight eachother here. Let me think abt the info u have given. Im having a real busy time.I'll be back soon with the points for u. Thank u.
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 17120656
I suggest a split : sciuriware {http:#16877083}, Webstorm {http:#16877124}, ksivananth {http:#16878605}
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 17120663
... and mayankeagle {http:#16880189}
0
 
LVL 35

Expert Comment

by:girionis
ID: 17120665
thanks, this is very helpful :)
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

656 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