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

 
 

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

Advertisement

Related Tags for SCJP Module-1 Question-8:


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 7, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com