• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why Abstract class is abstract?  RSS feed

 
praveen murali
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been reading a lot about abstract classes and wonder why actually it is Abstract? Now I do know that, what abstract is and what it means in terms of programming. What I am looking for is -
1) How does an abstract class behave in JVM environment ?
2) Someone told me that footprint of these classes on system memory is null, is it right ?
3) Does the abstract class exist on the java heap, irrespective of the fact that it has been re used or not?

I tried looking for these answers on the net, but nothing has come up yet, if you have a link to guide, thanks much .

I will post if I come across something worth reading.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
praveen murali wrote:I have been reading a lot about abstract classes and wonder why actually it is Abstract? Now I do know that, what abstract is and what it means in terms of programming. What I am looking for is -
1) How does an abstract class behave in JVM environment ?

Just like any other class. I don't understand the question.

2) Someone told me that footprint of these classes on system memory is null, is it right ?

Erm ... see 1.

3) Does the abstract class exist on the java heap, irrespective of the fact that it has been re used or not?

If you mean an instance of an abstract class, then it doesn't exist at all. Abstract classes need to be extended before they can be used.

I tried looking for these answers on the net, but nothing has come up yet, if you have a link to guide,

Best one I know.

Winston
 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im not sure what exactly is making you get confused so much.
I will give you one general example. Please note that this is just an example and may not be a real time scenario.

Lets assume, that company A makes a car body, engine, front glass, mirrors and almost everything expect wheels. There is another company B which makes wheels but doesn't actually make the entire car.
Now Company A cannot directly release a car in market right? but Company B can buy a car structure without wheels from company A and attach wheel to it and release a car in market.

Same thing happens with Java. Company B can place a Car Object into memory but company A cannot. But company A can refer a car object created by company B because it knows everything about that car except wheels.

Now hope this explanation clears your doubt about abstraction.
 
praveen murali
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am so sorry, that my too many questions got you off guard. I am aware what abstraction is in java and thanks to Mahesh, its more clear now. All I was looking for was the impact an abstract class has on memory, after being instantiated, like do we really go back to the abstract class and load it into memory, from your replies, it seems not . So I guess I will go with that for now.

Thanks a lot guys
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
praveen murali wrote:All I was looking for was the impact an abstract class has on memory, after being instantiated, like do we really go back to the abstract class and load it into memory...

These sorts of questions are rarely of much use in Java. It isn't C or C++ where classes have a predictable memory footprint and format; and in 11 years of using Java I've never had to think about what a class looks like in memory or where it gets loaded. The JVM loads it, I use it; simple as that. When I'm done with it, it collects it whenever it feels like it.

Winston
 
praveen murali
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Winston
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you know about abstraction? It has hardly anything to do with abstract classes.
 
BalaMurali dhar
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract class : abstract class is a class that contains one or more abstract method. Abstract method means that is being declared but contains no implementation.
Note : 1) If even a single method is abstract, the whole class must be declared abstract
2) Abstract class may not be instantiated, and require subclasses to provide implementations for the abstract methods.
3) You cannot mark a class as both abstract and final
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BalaMurali dhar wrote:Abstract class : abstract class is a class that contains one or more abstract method...

Actually, you're wrong there. An abstract class is a class with the word abstract in its definition; it doesn't have to have abstract methods (although more often than not it will).

Everything else you said is fine.

Winston
 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agree with Winston.
Having abstract method is not mandatory for an abstract class. Basically the purpose of abstract class is to indicate that you should (not must, when there is no abstract method) customize the behavior of this class before using it.
Abstract class gives you a template with some default behavior.
 
praveen murali
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Are you sure you know about abstraction? It has hardly anything to do with abstract classes.


yes, though I was looking for in terms of Abstract classes in Java, not Abstraction in general.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!