I have an Abstract class that is like:
public abstract class myClass{
public abstract double methodOne();
// returns the data member value for standard deviation
public abstract double methodTwo(String myString, int myInt);
// returns the data member value for mean percentage
}
Then I have a class which extends this:
public class Abstract extends myClass{
public double methodOne() {
return 0.00;
}
public double methodTwo(String myString, int myInt) {
return 20.00;
}
}
Then finally I have a normal method that’s return type is myClass.
public myClass anotherMethodOfMine(String myString, int myInt){
}
A simple question really, I just don’t understand how a method can return another class that itself contains methods? Could someone explain it to me?
The method returns an object of
MyClasson which you can call the methods defined there.You should understand that a class is just a definition of behaviour and data. An object is the actual entity that can perform things with data and can invoke the behaviours defined in the class.