Which of the following is the correct way to declare an abstract method in C#?
easy📝 Syntax Q12 of 15
C Sharp (C#) - Polymorphism and Abstract Classes
Which of the following is the correct way to declare an abstract method in C#?
Apublic abstract void Display() {}
Bpublic abstract void Display();
Cabstract public void Display() {}
Dpublic void abstract Display() {}
Step-by-Step Solution
Solution:
Step 1: Recall abstract method syntax
Abstract methods have no body and end with a semicolon, declared with the 'abstract' keyword before the return type.
Step 2: Validate each option
public abstract void Display(); matches the correct syntax. public void abstract Display() {} and C have wrong keyword order or include a body. public abstract void Display() {} incorrectly includes a method body.
Final Answer:
public abstract void Display(); -> Option B
Quick Check:
Abstract method = declaration only, no body [OK]
Quick Trick:Abstract methods end with semicolon, no braces. [OK]
Common Mistakes:
MISTAKES
Adding method body to abstract methods.
Wrong keyword order in declaration.
Using braces {} with abstract methods.
Master "Polymorphism and Abstract Classes" in C Sharp (C#)
9 interactive learning modes - each teaches the same concept differently