Showing posts with label abstract modifier. Show all posts
Showing posts with label abstract modifier. Show all posts

Java- abstract modifier / Chapter -3/ Access Modifier



Java- abstract modifier


the abstract is a modifier applicable for classes and methods but not for variables.

1 . abstract method:-
If we don't know about implementation even though we have to declare the method then we should go for abstract method.
In the abstract method, the only declaration is available but not the implementation that's why abstract method declaration should end with "; " semicolon.


example:-
public abstract void m1( ) ;           correct
public abstract void m1( ){ }          incorrect

Child class is responsible to provide implementation for parent class abstract method.

example:-

abstract class Parent
{
    public  abstract int salary() ;
}


class Child1 extends Parent
{
    public int salary( )
    {
           return 70000;   
    }
}

Java- abstract modifier / Chapter -3/ Access Modifier

abstract modifier:-
the abstract is a modifier applicable for classes and methods but not for variables.

1 . abstract method:-
If we don't about implementation even though we have to declare the method then we should go for abstract method.
In the abstract method, the only declaration is available but not the implementation that's why abstract method declaration should end with "; " semicolon.


example:
 public abstract void m1( ) ;           correct
public abstract void m1( ){ }          incorrect

Child class is responsible to provide implementation for parent class abstract method.


example:-

abstract class Parent
{
    public  abstract int salary() ;
}

Flipkart End Of Season Sale






© Copyright 2017 Javabychetan.blogspot.com