Suppose I have two classes as following:
public class Button{
public void onClick(){ do something...}}
public class imageButton extends Button{
public void onClick(){...}
public void setImage(Image img){...}}
I know that I can declare a variable like this
Button btn1 = new imageButton();
or
imageButton btn2 = new imageButton():
but what are the differences? What exactly is the datatype of the first instance? If I used the first instance, why btn1.setImage(Image img) will give me an error?
Thank you.
setImage()resides inimageButtonclass and notButton.Button btn1 = new imageButton();Buttonnamedbtn1which is initialized with a new object of classimageButton