This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I know that abstract classes cannot be instantiated. I also know that this code is perfectly legal.
and produces the output 5. But what should be done to call twoo() (if it is not static) from main()(static ofcourse). We obviously cannot use an object because abstract classes cannot be instantiated and also not do Twooo.twoo() because a non static method cannot be called from a static context. Is there a way to do that? If so how?
Abstract classes cannot be directly instantiated, but concrete classes that extend them can be. So if twoo() was not static, it could still be called through instances of a subclass. There is no way to call a non-static method through a static context, abstract or no.