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

Class declaration syntax in C Sharp (C#) - Interactive Code Practice

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

Complete the code to declare a simple class named Car.

C Sharp (C#)
public [1] Car {
    // class body
}
Drag options to blanks, or click blank then click option'
Ainterface
Bstruct
Cclass
Denum
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'struct' instead of 'class' for class declaration.
Using 'interface' or 'enum' which are different types.
2fill in blank
medium

Complete the code to declare a public class named Person.

C Sharp (C#)
[1] class Person {
    // properties and methods
}
Drag options to blanks, or click blank then click option'
Apublic
Bprotected
Cprivate
Dinternal
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'private' which restricts access.
Using 'protected' which is for inheritance only.
3fill in blank
hard

Fix the error in the class declaration to make it valid.

C Sharp (C#)
public class [1] {
    // class body
}
Drag options to blanks, or click blank then click option'
ACar123
B123Car
CCar-Model
DCar Model
Attempts:
3 left
💡 Hint
Common Mistakes
Starting class name with a number.
Including spaces or hyphens in the class name.
4fill in blank
hard

Fill both blanks to declare a sealed class named Logger.

C Sharp (C#)
[1] sealed [2] Logger {
    // class body
}
Drag options to blanks, or click blank then click option'
Apublic
Bclass
Cstruct
Dprivate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'struct' instead of 'class'.
Using 'private' when 'public' is needed.
5fill in blank
hard

Fill all three blanks to declare an abstract class named Shape with public access.

C Sharp (C#)
[1] [2] [3] Shape {
    // class body
}
Drag options to blanks, or click blank then click option'
Aprotected
Babstract
Cclass
Dpublic
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'protected' instead of 'public'.
Omitting the 'abstract' keyword.
Using 'struct' instead of 'class'.