1.
Choose the best definition for a Class.
Correct Answer
B. An object definition, containing the data and function elements necessary to create an object
Explanation
A class is an object definition that contains the necessary data and function elements to create an object. In object-oriented programming, a class serves as a blueprint or template for creating objects, which are instances of that class. It defines the properties (data) that an object can have and the behaviors (functions or methods) that the object can perform. By creating multiple objects from a class, we can efficiently organize and manage our code, as well as reuse and extend functionality.
2.
Choose the best definition of an object
Correct Answer
B. An instance of a class
Explanation
An object can be defined as an instance of a class. In object-oriented programming, a class is a blueprint or template that defines the properties and behaviors of an object. An object, on the other hand, is a specific instance of that class, created based on the defined blueprint. It encapsulates both data (properties) and functionality (behaviors) within itself. Therefore, an object can be considered as an instance of a class.
3.
Choose the appropriate data type for this value: "dog"
Correct Answer
B. String
Explanation
The value "dog" represents a word or text, which is best represented by the data type String. The String data type is used to store sequences of characters, such as words or sentences, in programming.
4.
Choose the appropriate data type for this value: true
Correct Answer
D. Boolean
Explanation
The value "true" represents a boolean data type. A boolean data type can only have two possible values, either true or false. It is used to represent logical values and is commonly used in programming to make decisions or comparisons. In this case, since the value is "true", the appropriate data type would be boolean.
5.
Choose the appropriate data type for this value: 1
Correct Answer
A. Int
Explanation
The value 1 is a whole number and does not have any decimal places, so it can be represented using the int data type. The int data type is used to store integer values in programming.
6.
Choose the appropriate data type for this value: 5.5
Correct Answer
B. Double
Explanation
The value 5.5 is a decimal number, which cannot be accurately represented using an int data type. The double data type, on the other hand, can store decimal numbers with precision. Therefore, the appropriate data type for the value 5.5 is double.
7.
Choose the appropriate data type for this value: A
Correct Answer
C. Char
Explanation
The appropriate data type for the value "A" would be char. The value "A" is a single character and can be represented using the char data type, which is used to store single characters in programming languages. The int data type is used for storing integers, the double data type is used for storing decimal numbers, and the String data type is used for storing a sequence of characters. However, since the value is a single character, char is the most suitable data type.
8.
Choose the appropriate data type for this value: "1"
Correct Answer
A. String
Explanation
String's always have " " around them!
9.
Choose the appropriate data type for this value: female
Correct Answer
A. Boolean
Explanation
male / female = boolean (only two possible answers)
10.
Choose the appropriate data type for this field: kindOfBird
Correct Answer
A. String
Explanation
example: kindOfBird = "Parrot"
11.
Choose the appropriate data type for this field: numberOfEggs
Correct Answer
D. Int
Explanation
The appropriate data type for the field "numberOfEggs" would be int because it is a whole number that represents a quantity. The other data types, such as double, char, and boolean, are not suitable for this field as they are used for different purposes. Double is used for decimal numbers, char is used for single characters, and boolean is used for true/false values.
12.
Choose the appropriate data type for this field: weightInKilos
Correct Answer
C. Double
Explanation
The appropriate data type for the field "weightInKilos" would be double. This is because weight is typically represented as a decimal number and the double data type can store decimal values with a larger range and precision compared to other data types like int or float.
13.
Choose the appropriate data type for this field: isSwimmer
Correct Answer
B. Boolean
Explanation
isSwimmer - yes or no (only two possible answers = boolean)
14.
Choose the appropriate data type for this field: eggColour
Correct Answer
D. String
Explanation
The field "eggColour" suggests that it is used to store the color of an egg. Since egg colors can vary and are not limited to a specific set of values, a String data type would be appropriate to store this information. A String data type allows for storing alphanumeric characters, making it suitable for storing a variety of egg colors.
15.
Use the screen shot of this project to answer the question.How many classes are there?
Correct Answer
A. 1
Explanation
Based on the provided screenshot, it can be observed that there is only one class present. This can be determined by counting the number of class boxes or sections visible in the screenshot. As there is only one class box visible, the correct answer is 1.
16.
How many objects are there?
Correct Answer
B. 2
Explanation
The correct answer is 2 because there are two objects mentioned in the given options.
17.
How many fields are there
Correct Answer
D. 4
Explanation
The correct answer is 4 because there are four options given in the question. Each option represents a field, so the number of fields is equal to the number of options provided.
18.
What is the name of the 1st field?
Correct Answer
dogName
Explanation
The name of the first field is "dogName".
19.
What is the name of the 4th field?
Correct Answer
neuteredStatus
Explanation
The name of the 4th field is "neuteredStatus".
20.
What is the data type of the 1st field?
Correct Answer
String
Explanation
The data type of the 1st field is string.
21.
What is the data type of the 3rd field?
Correct Answer
double
Explanation
The data type of the 3rd field is double.
22.
Which of the following always need a Capital letter ?
Correct Answer
A. Class names and Strings
Explanation
Class names and Strings always need a capital letter because it is a convention in programming to use capital letters for class names to distinguish them from other variables or objects. Additionally, capitalizing the first letter of a String is a common practice to improve readability and make the code more understandable.
23.
What is the name of the highlighted area?
Correct Answer
B. Constructor
Explanation
The highlighted area in the question is likely referring to a specific part of a code or diagram. In programming, a constructor is a special method that is used to initialize an object. It is typically called when an object is created and is used to set the initial values of the object's attributes. Therefore, the correct answer for the name of the highlighted area would be "constructor".
24.
What is the role of the constructor?
Correct Answer
B. Create an instance of a class (an object)
Explanation
Constructors have one purpose in life: to create an instance of a class. This can also be called creating an object.
25.
What is the name of this Class?
Correct Answer
A. Dog
Explanation
The correct answer is "Dog" because it is the only option that is capitalized, indicating that it is a proper noun and likely the name of a class. The other options, "dog1" and "dog2," are not capitalized and therefore do not fit the criteria of being a class name.