Hi,
My question is:
if super class is abstract, the subclass must be abstract or all methods must be abstract? please read follow:
I do execise questions of Marcus Green Mock No.1 . I found the question is following:
it explain that: Any class derived from an abstract class must either define all of the abstract methods or be declared abstract itself.
==============================
abstract class MineBase {
abstract void amethod();
static int i;
}
public class Mine extends MineBase {
public static void main(
String argv[]){
int[] ar=new int[5];
for(i=0;i < ar.length;i++)
System.out.println(ar[i]);
}
}
3) Error Mine must be declared abstract Any class derived from an abstract class must either define all of the abstract methods or be declared abstract itself.
==================
But I found another question in Marcus Green Mock No.2. it same Structure, but different result:
abstract class Base{
abstract public void myfunc();
public void another(){
System.out.println("Another method");
}
}
public class Abs extends Base{
public static void main(String argv[]){
Abs a = new Abs();
a.amethod();
}
public void myfunc(){
System.out.println("My func");
}
public void amethod(){
myfunc();
}
}
1) The code will compile and run, printing out the words "My Func"