-
Abstract, final and static keywords
Question asked by visitor sandhya
Hi
i am a bit confused between the abstract, final and static keywords as final cannot be overriden and static cannot be inherited i want to know whether static can be overridden and final can be inherited and whether abstract can be overridden and inherirted ?
thanks in advance ! !!
-
Junior Member
Re: Abstract, final and static keywords
Hi,
Abstract class-All the methods in it are abstract means they have no implementation. We can extend the abstract class and implement the methods in it and one more thing is we need to give the implementation to all the abstract mehods otherwise the subclass also become an abstract class.
Abstract class is one that contains atleast one abstract method with no implementation.We can't instatiate an abstract class.
Final Class- Final itself specifies that it neither be instantiated nor be extended.
static class-Means without instantiation we can use the methods and variables in it using the class name itself.
Static members can accessconly static data. Nonstatic members can access both static and nonstatic data.
Regards..
-
Contributing Member
Re: Abstract, final and static keywords
ABSTRACT:
- the class can be extendable but we can't instantiate that.
- the class must be used if you declare.
FINAL:
- if you apply on the class, which can not be extendable.
- if you apply on methods, those are not overridden.
-if you apply on variables, those are not reinitialized.
STATIC:
- those methods and block can be invoked before creating an instantiation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules