ERROR - The abstract method in type can only set a visibility modifier, one of public or protected


Error

The abstract method in type can only set a visibility modifier, one of public or protected.


Error Type 

Compile Time


Sample Code 

public abstract class ParentTest {
    private String element = "Hello";

    private abstract String getString();
    
    public void method(){
    getString();
    }
}

Cause

Abstract methods can only be declared either protected or public in the parent class.

Resolution

Either change the access to protected or public  

public abstract class ParentTest {
    private String element = "Hello";

    public abstract String getString();
    
    public void method(){
     getString();
    }
}
or 

make the method non abstract.

public abstract class ParentTest {
    private String element = "Hello";

    private String getString(){};
    
    public void method(){
     getString();
    }
}