placeholder image to represent content

Unity - Create with Code - Unit 4 Review

Quiz by Kelly Herbert

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
10 questions
Show answers
  • Q1

    You’re trying to write some code that creates a random age between 1 and 100 and prints that age, but there is an error. What would fix the error?

    Question Image

    Change line 1 to “private float age”

    Add the word “int” to line 8, so it says “int age = …”

    On line 7, change the word “private” to “void”

    Add a new line after line 8 that says “return age;”

    300s
  • Q2

    The following message was displayed in the console: “Monica has 20 dollars”. Which of the line options in the PrintNames function produced it?

    Question Image

    Option A

    Option B

    Option C

    Option D

    300s
  • Q3

    The code below produces “error CS0029: Cannot implicitly convert type 'float' to 'UnityEngine.Vector3'”. Which of the following would remove the error?

    Question Image

    On line 1, change “Vector3” to “float”

    On line 3, change “=” to “+”

    Either A or B

    None of the above

    300s
  • Q4

    Which of the following follows Unity’s naming conventions (especially as it relates to capitalization)?

    Question Image

    Line A

    Line B

    Line C

    Line D

    300s
  • Q5

    You are trying to assign the powerup variable in the inspector, but it is not showing up in the Player Controller component. What is the problem?

    You cannot declare a powerup variable in the Player Controller Script

    You cannot assign GameObject type variables in the inspector

    The powerup variable should be public instead of private

    The PlayerController class should be private instead of public

    300s
  • Q6

    Your game has just started and you see the error, “UnassignedReferenceException: The variable playerIndicator of PlayerController has not been assigned.” What is likely the solution to the problem?

    Question Image

    PlayerController variable in the playerIndicator script needs to be declared

    The playerIndicator variable needs to be made private

    The PlayerController script must be assigned to the player object

    An object needs to be dragged onto the playerIndicator variable in the inspector

    300s
  • Q7

    You are trying to create a new method that takes a number and multiplies it by two. Which method would do that?

    Question Image

    Method A

    Method B

    Method C

    Method D

    300s
  • Q8

    Which comment best describes the code below?

    Question Image

    // If the player collides with an enemy, destroy the enemy

    // If the enemy collides with a spike, destroy the spike

    // If the enemy collides with a spike, destroy the enemy

    // If the player collides with a spike, destroy the spike

    300s
  • Q9

    The code below produces the error, “error CS0029: Cannot implicitly convert type 'UnityEngine.GameObject' to 'UnityEngine.Rigidbody'”. What could be done to fix this issue?

    Question Image

    On line 1, change “collision” to “Rigidbody”

    On line 2, change “gameObject” to “Rigidbody”

    On line 3, delete “.gameObject”

    On line 3, add “.GetComponent()” before the semicolon

    300s
  • Q10

    Which of the following statements about functions/methods are correct:

    A and B are correct

    Only B is correct

    B and C are correct

    Only D is correct

    None are correct

    300s

Teachers give this quiz to your class