i have an exercise to solve, i have the correct answer, but I can't get it... Could someone help me what is happening after every "step". here's the exercise. We have 2 classes: enter code here
public class CA
{ 
    protected String descricao;
    private float valor;
    public CA(String descricao, float valor)
    {
        this
        .descricao = descricao;
        this.valor = valor;
    }
    public String getDescricao()
    {
        return descricao;
    }
    public float getValor()
    {
        return valor;
    }
    public float teste(float a)
    {
        return soma(a);
    }
    public float soma(float a)
    {
        return valor + a;
    }
}
and the second :
public class CB extends CA
{
    private final int maxStock = 15;
    private int stock;
    public CB(String descricao, float valor)
    {
        super(descricao,valor);
        stock = 0;
    }
    public int getStock()
    {
        return stock;
    }
    public void setStock(int actual)
    {
        stock = actual;
    }
    public int emFaltaStock()
    {
        return (maxStock-stock);
    }
    public float soma(float a)
    {
        return getValor() + a * 2;
    }
    public boolean noLimite(int minStock)
    {
        return ((minStock-stock) <= 0);
    }
}
The question is what will be the result of these statements:
CB cb1 = new CB("cb1",10);
CA ca1 = cb1;
float v1= ca1.soma(2);
I know it will be 14, but why? Can anyone tell me?
 
     
     
     
     
    