Recall & Review
beginner
What is the basic syntax to declare a class in C#?Use the keyword <code>class</code> followed by the class name and curly braces. Example:<br><pre>class MyClass { }</pre>Click to reveal answer
beginner
What keyword is used to declare a class in C#?The keyword
class is used to declare a class.Click to reveal answer
beginner
Can a class in C# contain methods and variables?Yes, a class can contain variables (fields) and methods (functions) inside its curly braces.Click to reveal answer
beginner
How do you declare a public class named <code>Car</code> in C#?Use the <code>public</code> access modifier before the class keyword:<br><pre>public class Car { }</pre>Click to reveal answer
beginner
What is the purpose of curly braces <code>{ }</code> in a class declaration?Curly braces define the body of the class where you put variables, methods, and other members.Click to reveal answer
Which keyword is used to declare a class in C#?
✗ Incorrect
The
class keyword declares a class in C#.What symbol is used to enclose the body of a class?
✗ Incorrect
Curly braces
{ } enclose the class body.How do you declare a class named
Person that is accessible from other classes?✗ Incorrect
Use
public to make the class accessible from other classes.Which of these can be inside a class body?
✗ Incorrect
Classes can contain both variables (fields) and methods.
What is the correct way to start a class declaration named
Animal?✗ Incorrect
The correct syntax is
class Animal { followed by the class body.Explain how to declare a simple class in C# including access modifier and body.
Think about the keywords and symbols you use to start and end a class.
You got /4 concepts.
Describe what can be included inside a class body in C#.
What parts make up the behavior and data of a class?
You got /4 concepts.