aspose file tools*
The moose likes Beginning Java and the fly likes OOPS Concept Abstraction with example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "OOPS Concept Abstraction with example" Watch "OOPS Concept Abstraction with example" New topic
Author

OOPS Concept Abstraction with example

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I am new to java. In java OOPS concept Abstraction means abstract or something. Please explain it with one example
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 157
Rajendra Prakash wrote:In java OOPS concept Abstraction means abstract or something.

Abstraction is a concept that hides the complexity, it says what it does, but not how it is done.

R6i
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 254

Abstraction is a concept that hides the complexity, it says what it does, but not how it is done.


Then what is encapsulation. Can you please give an example mentioning what is Abstraction and what is encapsulation.


Regards
Salil Verma
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 157
Salil Vverma wrote:
Abstraction is a concept that hides the complexity, it says what it does, but not how it is done.


Then what is encapsulation. Can you please give an example mentioning what is Abstraction and what is encapsulation.


encapsulation is one of the approaches to achieve Abstraction.
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 157
The abstraction can be used/applied in various situations/purposes:

data abstraction, operational abstraction, functional abstraction, procedural abstraction, behavioral abstraction etc.,
I can say
1. ADT's (Abstract Data Types) or structures (struct) in C/C++, classes in C++/Java are Examples for data abstraction
2. operators are examples for operational abstraction
3. functions are examples for functional abstraction
4. procedures in Pascal/FORTRAN/BASIC/COBOL are examples for procedural abstraction
5. classes in C++/Java are examples for behavioral abstraction(Here, we can say, both data abstraction and functional abstraction are combined, and of course, called encapsulation.)
similarly other types of abstractions.

Example for operational abstraction:here the operator *provides abstraction for multiplication operation, means the programmer/user can understand that the operator * will perform multiplication operation on 5 and 6 and then returns the product 30 to prod.
But it will not say how this multiplication takes place. The underlying Language processor (compiler/interpreter) will take care how to multiply numbers.

Depending on the complexity of the situation (problem/program/application/etc.,) the abstraction is achieved at several levels.
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 254

Hey Rayapudi,
That was very nice explanation.
Thanks for clearing my doubt.
 
jQuery in Action, 2nd edition
 
subject: OOPS Concept Abstraction with example