Home Tutorial Java Scjp Part1 SCJP Module-1 Question-24

 
 

SCJP Module-1 Question-24
Posted on: July 21, 2010 at 12:00 AM
The Sample program given below will test your understanding about the abstract class in Java.

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.

Answer:

(D)

Related Tags for SCJP Module-1 Question-24:


Ask Questions?

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.