What will happen after the following code is compiled and executed?

abstract public class Parent {
    String s = "hello!";
    public void test() {
        System.out.println(s);
    }
}

class P {
    public static void main(String[] args) {
        Parent p = new Parent();
        p.test();
    }
}
Explanation
It is not allowed to create an instance of an abstract class by using a new operator, as it is not completely defined

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Parent is abstract; cannot be instantiated at P.main

2016 Mar 19, 7:15:06 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback