0

I have started learning Java, and have come across this example, on this page:

abstract class Writer {
 public static void write() {
 System.out.println("Writing...");
 }
}
class Author extends Writer {
 public static void write() {
 System.out.println("Writing book");
 }
}
public class Programmer extends Writer {
 public static void write() {
 System.out.println("Writing code");
 }
 public static void main(String[] args) {
 Writer w = new Programmer();
 w.write();
 }
}

Of the options available for the result of this code, it says that the right answer is:

Writing...

How does it work exactly then, I thought the methods we write in the class that extends abstract class override the methods in the abstract class, but here the answer suggest otherwise.

Leff
  • 1,968
  • 24
  • 97
  • 201

0 Answers0