Menu
Question Index
...

What will be the output of the following program?

public class AbstractClass {
    public static void main(String[] args) {
        Shape shape1;  // LINE A
        Shape shape2 = new Shape(); // LINE B
        System.out.println("Compiles Successfully");
    }
}
abstract class Shape {}
class Rectangle extends Shape {}


Compiles Successfully
Compilation Error at LINE A because object is not created.
Compilation Error at LINE B because object is creating to the abstract class Shape.
Compilation Error or Runtime Error for some other reason

Doubts

Problems

Topic: Java Abstract Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App