Designing Classes - AP Computer Science A
Card 0 of 55
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
Compare your answer with the correct one above
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
Compare your answer with the correct one above
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Compare your answer with the correct one above
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
Compare your answer with the correct one above
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
Compare your answer with the correct one above
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Compare your answer with the correct one above
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Compare your answer with the correct one above
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
Compare your answer with the correct one above
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
Compare your answer with the correct one above
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Compare your answer with the correct one above
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
Compare your answer with the correct one above
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
Design a class, SuperHero, that will be used for an existing application. The class should extend the parent class Man. The class should define clothes, skin color, hair color, eye color, good or evil, whether or not powers are had, and a list of personality traits. The class Man supports an implementation of the method doGood. Here is the method stub for doGood:
public String doGood(Boolean good);
Your class will need to support an implementation of doGood.
Choose the best answer.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
This is the correct answer because the class extends the super class Man. It also lists all of the attributes defined in the prompt. In addition to listing all of the attributes, the class also defines an implementation of the doGood method which the prompt states is defined by the parent. One of the answer choices simply defined the stub for the method. The prompt clearly states to support an implementation of the method.
Compare your answer with the correct one above
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Compare your answer with the correct one above
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
Compare your answer with the correct one above
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
Compare your answer with the correct one above
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Compare your answer with the correct one above
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Which of the following lines represents a data member?
1. class animal
2. {
3. public:
4. animal();
5. void fetch();
6. private:
7. char bone;
8. }
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Data members are variables created in a class, and are typically found under the private: label, as data members are typically kept local to that class. It can be distinguished from member functions because of its lack of parenthesis().
Compare your answer with the correct one above
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
Which of the following operations allow you to define the function func1() outside of the class definition?
1. class school
2. {
3. public:
4. school();
5. void func1();
6. private:
7. char class;
8. }
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
The function template for func1() has been defined in the class definition, however the implementation of the function has not. In order to specify what the function does, you must say
classname::functionname()
{
}
Or, in our case,
school::function1()
{
//function definition goes in here
}
Compare your answer with the correct one above
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
Design a shell for a class named Dog that has 3 attributes:
- Does the dog have a tail?
- Is the dog purebred?
- A list of strings of definitive features for the dog
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
In the prompt, any yes or no questions should be addressed as booleans (i.e. tail, purebred). Any lists should have the type and name of the list. This was just a shell, so there should be no declarations of variables.
Compare your answer with the correct one above
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
The letters above the code samples are for the explanation.
Design a class in the programming language Swift (iOS) to best solve this problem:
I have a dog company. My company takes in dogs for boarding on the weekdays, weekends, and during holidays. I want my website to display when we're open, how many spots we have left, and the price for boarding.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Coding sample (A) is the correct answer. This is due to the completeness of the class. The class has getters for open, spotsLeft, and price which is what the user in the prompt asks for to be able to display them on a website.
Coding sample (B) is incorrect because everything is set to private. If the getter functions are private, then the user cannot use them for the website.
Coding sample (C) is incorrect because there are no return types on the functions. In Swift, the functions must have return types.
Coding sample (D) is incorrect because it is just the shell of a class and does not actual perform any functions.
Compare your answer with the correct one above