| Author |
Practical example for Abstraction
|
rajaraman navaneethan
Ranch Hand
Joined: Feb 26, 2005
Posts: 85
|
|
hi friends, can any one give a practical example of the Abstraction concept in a java program? i can understand that abstraction means Through the process of abstraction, a programmer hides all but the relevant data aboutan object . is the following program an example of Abstraction public class OOP { public float cal(float a,float b) { return a*b; } } public class XYZ { public static void main(String args[]) { OOP obj=new OOP(); obj.cal(12.3f,10.2f); } } here in the class OOP,the cal method calculates the product of 2 floating point numbers.class XYZ calls the method cal thru the object obj.it does not know the implementation of the cal method,but it gets the o/p. similarly if we declare a variable int i=10; a 32 bit holder is assisgned to i, which happens behind the scenes. are the 2 cases above a valid example for abstraction,if not please give a practical example of the concept of abstraction in java regards, Raja
|
 |
 |
|
|
subject: Practical example for Abstraction
|
|
|