aspose file tools*
The moose likes Beginning Java and the fly likes Abstract Method & Static Abstract Class, Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract Method & Static Abstract Class, Methods" Watch "Abstract Method & Static Abstract Class, Methods" New topic
Author

Abstract Method & Static Abstract Class, Methods

Kalyan Naveenan
Greenhorn

Joined: Jul 23, 2011
Posts: 12
Now that i understood the concept abstract method can someone help me in understanding when and why is there a use for abstract method. Secondly i would like to know if there is a possibility of using an abstract static class in java so that even though instantiation is not allowed, is there a chance of accessing the methods and instance variables from another class ?
Keith Rainey
Ranch Hand

Joined: Jan 19, 2011
Posts: 66

You would use an abstract class as the basis for other more specific subclasses. For instance, you might abstract the Vehicle class with subclasses Tricycle, Bicycle, Car


You can specify the common elements that all the types will have ( color, numberOfWheels, etc) , the things they must be able to do ( start , stop, accelerate, decelerate, etc). The abstract class will NOT specify *how* the subclasses will implement them. A tricycle will have a different number of wheels than a car and it will perform all the behaviors (methods) differently.


Keith Rainey
OCPJP6
Keith Rainey
Ranch Hand

Joined: Jan 19, 2011
Posts: 66

One point of clarification: you can also have concrete methods in an abstract class. All subclasses will contain those members.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

Kalyan Naveenan wrote: Secondly i would like to know if there is a possibility of using an abstract static class in java so that even though instantiation is not allowed,

There is no abstract static classes in Java


Mohamed Sanaulla | My Blog
Kalyan Naveenan
Greenhorn

Joined: Jul 23, 2011
Posts: 12
thanks Keith Rainey and Mohamed Sanaulla for the explanation.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Mohamed Sanaulla wrote:
Kalyan Naveenan wrote: Secondly i would like to know if there is a possibility of using an abstract static class in java so that even though instantiation is not allowed,

There is no abstract static classes in Java

There can be - static abstract nested classes. No top-level class can be static, no matter if the class is abstract or not.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract Method & Static Abstract Class, Methods