1/26
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
A student is developing a class that will store information about pets, including each pet's name and age. Which set of attributes is most appropriate?
One String for the name and one int for the age
A student is developing a Player class that should allow access and modification of the score. Which attributes/behaviors are most appropriate?
A score attribute with getScore and setScore methods
A programmer reduces testing to speed up development. What is the most likely consequence?
Decreased system reliability
A software company created a program to help a community. Which statement is true about the program?
It could have unintended harmful effects beyond its intended use
Why do programmers often include open-source code in their programs?
To reuse implemented algorithms while reducing intellectual property concerns
Given Item class with private double price and public String name, code segment I accesses price, code segment II accesses name. Which prints?
Code segment II prints the name; code segment I does not compile
Candy class has public instance variables but should prevent modification. What change is needed?
Make the instance variables private
Which declaration is most appropriate for the Profile class with name, username, and followers hidden from external access?
public class Profile with private name, private username, and private followers
Person class missing constructor must allow Person p = new Person("Washington") to set name. Which constructor is correct?
public Person(String n) { name = n; }
Fruit class diagram missing quantity variable and method. Which replacements are most appropriate?
private int quantity and public int getQuantity()
Dog fido = new Dog(); printing name and age outputs what?
name: null, age: 0
Student("Bobby", 25) does not assign age correctly. What is the state of the object?
name is "Bobby" and age is 0
BankAccount deposit does not work: public void deposit(double amount){ double balance = balance + amount; }. Why not?
A local variable named balance shadows the instance variable, so the instance variable never updates
Thing apple = new Thing(5); Thing banana = new Thing(5); printing apple.mystery(banana) and banana.mystery(banana) outputs what?
maybe yes
Which code correctly completes Player.hasHigherScore(Player other)?
return this.getTotal() > other.getTotal();
Friend constructor uses name = name causing getName() to return null. What fix solves it?
Replace name = name with this.name = name
MyClass updateX leaves x unchanged when? updateX adds amount to x.
When the amount (num) is 0
In XYPoint.getPoint(), which code returns (x, y) correctly?
return "(" + x + ", " + y + ")";
Fraction.getDecimal() returns numerator/denominator. When does it fail to return a value?
When denominator is 0
mystery(String message,int x) returns message.substring(x). What happens for str1="abcde", str2=mystery(str1,3)?
str1 is unchanged; str2 becomes "de"
In getTax(Item myItem,double taxRate), which expression retrieves cost correctly?
myItem.getPrice()
Location clone method accesses private fields row and col. When does it work?
Only if defined inside the Location class
Which Widget.doSomething implementation allows Widget.doSomething() to compile?
public static int doSomething() { return word.length(); }
StringFinder code produces what output? jazz→target x then blaze→target a then zebra→target z
-1 2 0
ComputeObject s.sumProd(5) prints what?
100
Stars s = new Stars(3,2); s.draw(5); what prints?
then then * then ** then **** (one line each)
TestObject obj1=new TestObject(2.5); obj2=new TestObject(10.2); obj1.printTestObject() prints what?
2.5, 2