Share on Google+Share on Google+

SCJP Module-1 Question-8

The given program heps and tests the in understating of abstract classes in core Java and it is very useful for SCJP exam preparation.

Given a sample code:

1 class Ball {
2 abstract void sayHello();

3 class Football extends Ball {
4 void sayHello() {
5 System.out.println("hello");
6 }}

7 public class Sample2 {
8 public static void main(String args[]) {
9 Football f = new Football();
10 f.sayHello();
11 }}

What is the correct statement for the line number 1 ?

(1) Compilation succeeds no issue
(2) abstract
(3) interface
(4) public




 The abstract keyword must be place before the class Ball because abstract method can only exist in the abstract class not in concrete class.


Posted on: July 7, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.


Advertisement null