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

Why classes are needed in C Sharp (C#) - Test Your Understanding

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

Complete the code to declare a class named Car.

C Sharp (C#)
public [1] Car {
    // class body
}
Drag options to blanks, or click blank then click option'
Amethod
Bclass
Cvariable
Dinterface
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'method' or 'variable' instead of 'class' to declare a class.
Confusing 'interface' with 'class' keyword.
2fill in blank
medium

Complete the code to create an object of the Car class.

C Sharp (C#)
Car myCar = new [1]();
Drag options to blanks, or click blank then click option'
AVehicle
BClass
CObject
DCar
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different class name than the one declared.
Using 'Object' or 'Class' instead of the class name.
3fill in blank
hard

Fix the error in the code to access the Car's speed property.

C Sharp (C#)
int speed = myCar.[1];
Drag options to blanks, or click blank then click option'
ASpeed()
Bspeed()
CSpeed
Dspeed
Attempts:
3 left
💡 Hint
Common Mistakes
Adding parentheses when accessing a property.
Using incorrect capitalization.
4fill in blank
hard

Fill both blanks to define a method named Drive inside the Car class.

C Sharp (C#)
public [1] [2]() {
    Console.WriteLine("Driving");
}
Drag options to blanks, or click blank then click option'
Avoid
Bint
CDrive
DCar
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name as the method name.
Using a return type other than void when no value is returned.
5fill in blank
hard

Fill all three blanks to create a Car object, set its speed, and print it.

C Sharp (C#)
Car [1] = new Car();
[1].[2] = 60;
Console.WriteLine([1].[2]);
Drag options to blanks, or click blank then click option'
AmyCar
Bspeed
CSpeed
DcarSpeed
Attempts:
3 left
💡 Hint
Common Mistakes
Using different object names in different lines.
Using incorrect property names or capitalization.