Which of the following is the correct way to create an abstract class in Java?
2024
Which of the following is the correct way to create an abstract class in Java?
Answer: C. abstract class Demo { abstract void fun(); } — The correct Java syntax places abstract before class, and an abstract method has no method body. Therefore the valid declaration is abstract class Demo {…
- A.
class Demo { abstract void fun(); }
- B.
class abstract Demo { void abstract fun(); }
- C.
abstract class Demo { abstract void fun(); }
- D.
abstract class Demo { void fun() { abstract; } }
- E.
Question not attempted
Attempted by 299 students.
Show answer & explanation
Correct answer: C
The correct Java syntax places abstract before class, and an abstract method has no method body. Therefore the valid declaration is abstract class Demo { abstract void fun(); }.
Loading lesson…