File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOPS Concept Abstraction with example

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Salil Vverma
Ranch Hand
Posts: 255
Hibernate Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
M K Rayapudi
Ranch Hand
Posts: 160
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 160
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 255
Hibernate Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Rayapudi,
That was very nice explanation.
Thanks for clearing my doubt.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic