I have been preparing for the exam since nov 2005, but finaly had the k and b book last week, and I am writing on the 15 of march, I have read the book in ten days with all the chapters on a four hours daily rate. I have understand most of the things but I have so many confussing things there, and their questions too are very very scary, well check this out
1) class Sample{
public void me(){//do stuff}
}
class Sample2 extends Sampe{
public void me(){//do sub stuff}
static public void main(
String[] h){
Sample f=new Sample2();
f.me()//which me is called
Sample[] mess=new Sample[2];
mess[0]=new Sample();
mess[1]=new Sample2();
for(Sample s : mess){
s.me();//I believe this will do it specificaly
}
//what if I pass new Sample2 into a method that is expecting sample what wil execute
((Sample2)f).passSample(new sample2);//which me will execute
}
void passSample(Sampe s){
s.me();
}
}
finally I dont understand polymophism and how reference type variable defines the methods of called by and object nomatter what it refers to