---
title: "Quiz: Apply object-oriented principles"
content_type: quiz
url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/quiz/quiz-apply-object-oriented-principles?language=en"
language: en
container_type: pathway
container_title: "Junior Programmer"
container_url: "https://learn.unity.com/pathway/junior-programmer.md?language=en"
unit_title: "Apply Object-Oriented Principles"
unit_url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles?language=en"
standalone_markdown_url: "https://learn.unity.com/quiz/quiz-apply-object-oriented-principles.md?language=en"
previous_title: "Job preparation: Junior Programmer"
previous_url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/tutorial/job-preparation-junior-programmer-2?language=en"
previous_markdown_url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/tutorial/job-preparation-junior-programmer-2.md?language=en"
next_title: "Submission: Programming theory in action"
next_url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/tutorial/submission-programming-theory-in-action?language=en"
next_markdown_url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/tutorial/submission-programming-theory-in-action.md?language=en"
difficulty: beginner
duration_minutes: 15
question_count: 12
correct_answers_to_pass: 9
unity_version:
  - "6.0"
  - "2022.3"
  - "2021.3"
  - "6.3"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/quiz/quiz-apply-object-oriented-principles.md?language=en&version=6.0"
  - name: "2022.3"
    url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/quiz/quiz-apply-object-oriented-principles.md?language=en&version=2022.3"
  - name: "2021.3"
    url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/quiz/quiz-apply-object-oriented-principles.md?language=en&version=2021.3"
  - name: "6.3"
    url: "https://learn.unity.com/pathway/junior-programmer/unit/apply-object-oriented-principles/quiz/quiz-apply-object-oriented-principles.md?language=en&version=6.3"
last_updated: "2026-08-04T14:25:12.000Z"
---

# Quiz: Apply object-oriented principles

This quiz checks your understanding of object-oriented programming principles from the Junior Programmer mission.

This quiz will assess your understanding of the concepts covered in the  **Junior Programmer: Apply object-oriented principles** mission.

## Question 1

True or False:

In general, classes should be organized and written such that each class has a singular purpose.

_Select only one_

- True
- False

## Question 2

Why might you want to use an extension method in C#?

_Select only one_

- In order to extend the functionality of an existing method using the same method name.
- In order to add more parameters to an existing method.
- In order to add functionality to an existing type without creating a new derived type.
- In order to extend the access of an existing method so it can be accessed from other classes.

## Question 3

 Which of the following statements are true about parent (base) and child (derived) classes?

1. A class can only inherit from a single class.
2. Protected variables and methods can be accessed from the child class, even if they are separate scripts.
3. Private variables and methods can be accessed from the child class, even if they are separate scripts.
4. If Class C derives from Class B, which derives from Class A, Class C only inherits behaviors from Class B.

_Select only one_

- Only 1 is true.
- Only 1 and 2 are true.
- Only 2 and 3 are true.
- Only 3 and 4 are true.
- All are true.

## Question 4

If you were programming an application that allowed users to configure their own vehicles, how would you use the concept of inheritance to structure the code in a way that minimized redundancies?

_Select only one_

- Create a base “Car” class, then create derived classes for different types of cars.
- Create a namespace called “Cars” and put all vehicle types in that namespace.
- Create a method called “InheritCarBehavior”, which pulls in the functionality for a car.
- Create a “Car” event, and have all vehicle types inherit from that event.

## Question 5

A base class (Class A) includes the following code:

```csharp
public virtual void Greet () 
{
   Debug.Log("Hello");
}
```

A derived class (Class B) that derives from Class A includes the following code:

```csharp
public override void Greet ()
{
   Debug.Log("How are you?");
}
```

If only Class B is instantiated and the Greet() method is called, what will appear in the console?

_Select only one_

- Hello
- How are you?
- Hello

  How are you?
- Hello

  Hello

  How are you?

## Question 6

Which of the following practices are in support of the principle of “encapsulation” in C#?

1. Using getters and setters
2. Using public variables only when necessary
3. Deactivating objects in a scene that are not in use whenever possible.
4. Using events that communicate only to abstract classes.

_Select only one_

- 1 and 2 only
- 1 and 3 only
- 1 and 4 only
- 2 and 3 only
- 2 and 4 only
- 3 and 4 only

## Question 7

How would you replace the public variable below with a Property, which has improved security and still can be accessed from other classes.


```csharp
public int score;
```

_Select only one_

- private int score {protected};
- public Property score;
- public static property score;
- public int Score { get; set; }

## Question 8

How would you recommend improving the following code in order to improve its reusability?


```csharp
void DisplayInfo(string name1, string name2, string address1, string address2, string phone1, string phone2)
{
     print(name1);
     print(name2);
     
     print(address1);
     print(address2);
     
     print(phone1);
     print(phone1);

}
```

_Select only one_

- Use literal strings instead of variables within the print method calls.
- Have DisplayInfo return an array composed of all of the strings.
- Create new methods for DisplayNames, DisplayAddresses, and DisplayPhoneNumbers, then call each of those methods from DisplayInfo().
- Shorten the variable names to n1, n2, a1, a2, p1, and p2

## Question 9

 The following is an example of code logic that is very difficult to understand:

```csharp
public float GetValue()
{
     float result;      
     
     if (bool1)
     {
          result = 1;
      }
      else
      {
         if (bool2)
         {
            result = 2;
         }
         else
         {
            result = 0;
         }
     }
     return result;
 }
```

True or False: the code below would achieve the same result in a simpler way.

```csharp
public float GetValue() {
     if (bool1)
     {
         return 1;
     }
     if (bool2)
     {
         return 2;
     }
     return 0; 
}
```

_Select only one_

-  True
- False

## Question 10

Which of the following statements about variables is true?

_Select only one_

- Local variables can be accessed from all methods within a single class.
- A Property provides public access to a private variable with getters and setters.
- Public variables in derived (child) classes cannot be accessed by its base class.
- Private variables in base classes are only accessible from derived (child) classes.

## Question 11

When using the profiler to diagnose issues with CPU usage, where would you look to find optimization issues with custom scripts you have written for your application?

_Select only one_

- The EditorLoop
- The PlayerLoop
- The RunLoop
- The ScriptLoop

## Question 12

Which of the following scenarios is most likely to cause performance issues?

_Select only one_

- Making a mesh collider convex instead of leaving it in its default state.
- RigidBodies that are extremely far away from each other in a scene.
- An object with many RigidBodies, each with colliding joints.
- On a complex mesh, using a compound collider made of overlapping box and capsule colliders instead of using a mesh collider.
