Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

abstract data type  RSS feed

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone please explain what is an abstract data types in java?
thanks
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Reader,
This keyword is used wwhile declaring classes and methods.
For eg.


When used with a class, it does NOT allow any instantiations of it. It means you will not be able to create any object for the above class "MyAbstractClass". This is used when you are not sure about the implementation of the class and the class only gets its real meaning when its extended by some other class.

Absract methods are not given any body. They are only declared.
Note: I have used a semicolon after the method signature.

The body for the method is defined by any class that extends its class.

Here's an example:


You really don't know what an Animal object looks like. Does it have four legs or four horns. There is no definite meaning for it. So you NEED to subclass it to give it a proper shape such as a Dog.
Different Animals have different styles of walking, so we just declare an abstract method for walk() and leave it to the sub-classes to implement a specific style for its class.

Now, there are many rules associated with the "abstract" keyword which you can learn once you understand this concept.
 
author and iconoclast
Posts: 24203
43
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although the above is a good explanation of the "abstract" keyword in Java, it actually doesn't answer the question at all.

"Abstract data type" -- often abbreviated ADT -- is basically an old-fashioned term for "class". If you know what a Java class is -- especially if you understand it as some data plus some operations on that data -- then you understand what an ADT is.
 
Shyam Prasad Murarka
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Reader,
When I read "abstract data type" I though Jenny must have made a typo. I never knew any term such as "ADT" even existed! But thanks to Ernest, I am now aware of it.
 
Jenny raj
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi shyam

I know the concept of abstract
but as my other friend said i wanted to know what ADT is all about?

like where do we apply in java.

still i am not clear..

any suggestion would be appreciated

thanks
 
Shyam Prasad Murarka
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Reader,
Have you read Ernest's post properly. Everything about ADT is there! Like he told, its just an old-fashioned term for 'class'. I don't know if there's anything more to that.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to read the Wikipedia article: http://en.wikipedia.org/wiki/Abstract_data_type
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!