Given a sample code:
1 abstract class Shape {
2 private int x, y;
3 public void setValue(int x, int y) {
4 this.x = x;
5 this.y = y;
6 System.out.println(x+y);
}}
7 class Test {
8 public static void main(String args) {
9 Shape s = new Shape();
10 s.setValue(1, 2);
}}
What will be the result? Choose the correct option?
(A) Successful run and print 3.
(B) Runtime error.
(C) Compilation error at line no 1.
(D) Compilation error at line no 9 that cannot create instance.
(D)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.