0
0
C Sharp (C#)programming~10 mins

Interface vs abstract class decision in C Sharp (C#) - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an interface named IShape.

C Sharp (C#)
public interface [1] { void Draw(); }
Drag options to blanks, or click blank then click option'
AShape
BIShape
CAbstractShape
DShapeInterface
Attempts:
3 left
💡 Hint
Common Mistakes
Using a class name instead of an interface name.
Not following the naming convention for interfaces.
2fill in blank
medium

Complete the code to declare an abstract class named Shape.

C Sharp (C#)
public abstract class [1] { public abstract void Draw(); }
Drag options to blanks, or click blank then click option'
AShape
BIShape
CAbstractShape
DShapeInterface
Attempts:
3 left
💡 Hint
Common Mistakes
Using interface naming for abstract classes.
Confusing interface and abstract class names.
3fill in blank
hard

Fix the error in this class declaration that tries to inherit from an interface and an abstract class.

C Sharp (C#)
public class Circle : [1], IShape { public override void Draw() { } }
Drag options to blanks, or click blank then click option'
ACircleBase
BIShape
CAbstractShape
DShape
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to inherit from multiple classes.
Using interface name where abstract class is expected.
4fill in blank
hard

Fill both blanks to complete the interface and abstract class usage correctly.

C Sharp (C#)
public interface [1] { void Draw(); } public abstract class [2] { public abstract void Draw(); }
Drag options to blanks, or click blank then click option'
AIShape
BShape
CDrawable
DAbstractDrawable
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing interface and class naming conventions.
Using unrelated names for interface or abstract class.
5fill in blank
hard

Fill all three blanks to implement a class that inherits from an abstract class and implements an interface.

C Sharp (C#)
public interface [1] { void Draw(); } public abstract class [2] { public abstract void Draw(); } public class [3] : [2], [1] { public override void Draw() { } }
Drag options to blanks, or click blank then click option'
AIShape
BShape
CCircle
DDrawable
Attempts:
3 left
💡 Hint
Common Mistakes
Using interface name as class name.
Not overriding abstract methods properly.