I want to access and use 3 private variables in an Abstract Class(MainAbstract.java) from another class that has extended (SubAbstract.java) from the previously mentioned Abstract Class.
From the sub class I want to access the getters() and setters() of the main class's.
In the main class (this is an abstract class) there is an abstract method called ShowInfo().
This ShowInfo() abstract method should do something to view the each instance of the subclass's.
Below is the source code for the MainClass(Abstract) and the Sub Class SubAbstract. Please refer them.
MainAbstract.java
package abstractionexample;
public abstract class MainAbstract {
private String sName;
private String sType;
private int iQty;
public String getsName() {
return sName;
}
public void setsName(String sName) {
this.sName = sName;
}
public String getsType() {
return sType;
}
public void setsType(String sType) {
this.sType = sType;
}
public int getiQty() {
return iQty;
}
public void setiQty(int iQty) {
this.iQty = iQty;
}
public abstract void showInfo();
public static void main(String[] args) {
}
}
SubAbstract.java
package abstractionexample;
public class SubAbstract extends MainAbstract{
@Override
public void showInfo() {
}
//This is an instance and the getters() and setters() should use each instance of this kind of to get values and set values.
SubAbstract nSubAbs = new SubAbstract();
}