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
(2)
The abstract keyword must be place before the class Ball because abstract method can only exist in the abstract class not in concrete class.
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.