1 ]
a call super() is made by constructor of every subclass implicitely but is this true for methods also.(i. e) if a call is made to the method of subclass does it check for that method in the super class also.
the following code results in compile time error saying"method getFields() not found in class Base"
please explain
class Base {
}
class Agg extends Base{
public
String getFields(){
String name = "Agg";
return name;
}
}
public class Avf{
public static void main(String argv[]){
Base a = new Agg();
System.out.println(a.getFields());
}
}
2]why does this give me ans as 10,0 & 20
10,0 i can understand but if the valiue v.i has been made 10 then why does it give20 again.
please clarify.
class ValHold{
public int i = 10;
}
public class ObParm{
public static void main(String argv[]){
ObParm o = new ObParm();
o.amethod();
}
public void amethod(){
int i = 99;
ValHold v = new ValHold();
v.i=30;
another(v,i);
System.out.println(v.i);
}//End of amethod
public void another(ValHold v, int i){
i=0;
v.i = 20;
ValHold vh = new ValHold();
v = vh;
System.out.println(v.i+ " "+i);
}
//End of another
}