Correct, Aswer is C.
To test:
public class StockRoom {
private int stock = 10; // declare as static
private int qty; // declare as static
public void purchase(int q) {stock += q; this.qty = q;}
public void sell(int q) {stock -= q; this.qty = q;}
public void printStock(String action ) { declare as static
System.out.println(action + ":" + qty + " items. Stock in Hand: " + stock);
}
public static void main (String[] args) {
StockRoom k1 = new StockRoom();
k1.sell(5);
StockRoom.printStock("Sold");
StockRoom k2 = new StockRoom();
k2.purchase(5);
StockRoom.printStock("Purchased");
}
}
upvoted 4 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
carloswork
2 months, 1 week agocarloswork
2 months, 1 week ago