Test: AP Computer Science A

1.

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. 

class SuperHero extends Man {

List clothes;

String skinColor;

String hairColor;

String eyeColor;

Boolean good;

Boolean powers;

List personalityTraits;

public String doGood(Boolean good) {

}

}

class SuperHero extends Man {

List clothes;

String skinColor;

String hairColor;

String eyeColor;

 

public String doGood(Boolean good) {

String result = "No, do bad!";

if (good == true) {

result = "Yes, do good!";

}

return result;

}

}

class SuperHero extends Man {

List clothes;

String skinColor;

String hairColor;

String eyeColor;

Boolean good;

Boolean powers;

List personalityTraits;

 

public String doGood(Boolean good) {

String result = "No, do bad!";

if (good == true) {

result = "Yes, do good!";

}

return result;

}

}

class SuperHero {

List clothes;

String skinColor;

String hairColor;

String eyeColor;

Boolean good;

Boolean powers;

List personalityTraits;

public String doGood(Boolean good) {

String result = "No, do bad!";

if (good == true) {

result = "Yes, do good!";

}

return result;

}

}

1/12 questions

0%

Access results and powerful study features!

Take 15 seconds to create an account.
Start now! Create your free account and get access to features like:
  • Full length diagnostic tests
  • Invite your friends
  • Access hundreds of practice tests
  • Monitor your progress over time
  • Manage your tests and results
  • Monitor the progress of your class & students
By clicking Create Account you agree that you are at least 13 years old and you agree to the Varsity Tutors LLC Terms of Use and Privacy Policy.
Learning Tools by Varsity Tutors