Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As of my understanding abstraction is hiding how it works(what it does matters rather than how).

In interface all methods are abstract and in abstract class few methods are abstract and it has to be implemented or extended in a concrete class .So any way the implemented or extended class know how it functions so what is the meaning of abstraction in java programming. Or for whom it hides the working function.

What I have tried:

Please do clear my doubt with a real time example.(sorry if it's a simple question)
Posted
Updated 14-Jun-17 20:57pm

1 solution

abstract in the concept of interfaces and abstract classes is not to do with abstraction the technique for arranging complexity of computer systems.

Abstraction the technique (one the pillars of OOPS) isn't necessarily about "hiding" anything, but about establishing a level of complexity on which a person interacts with the system, suppressing the more complex details below the current level. It's like a car: you "know" it's made of blocks: A "seating area", a "luggage area", an "engine", a "braking system", a "steering system" because that is the level of abstraction at which most people interact with a vehicle - but in reality, they are normally not designed in isolation: the braking system interacts with the steering and engine to prevent skids for example (traction control) and so forth. And each of those "blocks" is built of much, much more complex subassemblies, many of which have multiple roles in multiple systems making up the whole vehicle.

abstract methods aren't the same - they are a way of "telling" the system that these are elements that must be provided by the implementation of the class in order to include the abstract class or interface in the code. It's a lot more like a membership of a club - the club has rules that must be followed or you may not be a member. For example, the "tea club" at work may have a "dues" you must pay every month in order to drink the tea - if you don't pay your dues, you are thrown out and can't drink the tea! When you derive from an interface of abstract class, the methods, properties and so forth are the "rules" you must obey - or in fact implement - in order to derive the new class.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900