• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OOPS Concept Abstraction with example

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 257
Hibernate Oracle Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Rayapudi,
That was very nice explanation.
Thanks for clearing my doubt.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic