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

 
 

SCJP Module-1 Question-8
Posted on: July 7, 2010 at 12:00 AM
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

Answer

(2)

Explanations:

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

Related Tags for SCJP Module-1 Question-8:


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.