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


Share on Google+Share on Google+
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.




Related Tags for SCJP Module-1 Question-24:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 21, 2010

Recommend the tutorial

Advertisements Advertisements