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

Object instantiation with new 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 create a new instance of the class Car.

C Sharp (C#)
Car myCar = [1] Car();
Drag options to blanks, or click blank then click option'
Anew
Bcreate
Cmake
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create' or 'make' instead of 'new' causes a syntax error.
Forgetting the 'new' keyword leads to a compile-time error.
2fill in blank
medium

Complete the code to instantiate a Person object with the default constructor.

C Sharp (C#)
Person person = [1] Person();
Drag options to blanks, or click blank then click option'
Anew
Binit
Ccreate
Dmake
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'init' or 'create' instead of 'new' causes errors.
Omitting the keyword entirely results in a compile error.
3fill in blank
hard

Fix the error in the code to correctly instantiate a Book object.

C Sharp (C#)
Book myBook = [1]Book();
Drag options to blanks, or click blank then click option'
Amake
Bcreate
Cinit
Dnew
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out the space after the keyword causes syntax errors.
Using incorrect keywords like 'create' or 'make' leads to errors.
4fill in blank
hard

Fill both blanks to instantiate a Student object and assign it to a variable.

C Sharp (C#)
[1] [2] = new Student();
Drag options to blanks, or click blank then click option'
AStudent
Bvar
Cstudent
Dnew
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name twice causes syntax errors.
Using 'new' as a variable name is invalid.
5fill in blank
hard

Fill all three blanks to instantiate a Rectangle object with width and height parameters.

C Sharp (C#)
Rectangle [1] = new Rectangle([2], [3]);
Drag options to blanks, or click blank then click option'
Arect
B5
C10
Drectangle
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name as a variable name causes confusion.
Swapping the width and height values changes the rectangle size.