Question
QUESTION 1 What term is used to identify when an object hands off some functionality to another object? Delegate Client Slave Minion 2 points QUESTION
QUESTION 1
-
What term is used to identify when an object hands off some functionality to another object?
Delegate
Client
Slave
Minion
2 points
QUESTION 2
-
Given the inheritance tree in the accompanying figure, which is a list of all subclasses?
UnpoweredVehicle, PoweredVehicle
UnpoweredVehicle, PoweredVehicle, Bicycle, Skateboard, Motorcycle, Car
Bicycle, Skateboard, Motorcycle, Car
Cannot be determined from the diagram
2 points
QUESTION 3
-
What is the output of the following code? public class Rectangle{ // Instance variables private double length; private double width; // Getters and setters for length and width public double getLength(){ return length; } public void setLength(double length){ this.length = checkData(length); } public double getWidth(){ return width; } public void setWidth(double width){ this.width = checkData(width); } // Constructor public Rectangle(double length, double width){ this.length = checkData(length); this.width = checkData(width); } // Error-checking method public double checkData(double val){ // If value is negative, make it positive if(val
Rectangle 1: Length: 4.0 Width: 2.0 Area: 8.0 Perimeter: 12.0 Rectangle 2: Length: 8.0 Width: 6.0 Area: 48.0 Perimeter: 28.0
Rectangle 1: Length: -4.0 Width: 2.0 Area: -8.0 Perimeter: -12.0 Rectangle 2: Length: 8.0 Width: 6.0 Area: 48.0 Perimeter: 28.0
Rectangle 1: Length: -4.0 Width: 2.0 Area: -8.0 Perimeter: -4.0 Rectangle 2: Length: 8.0 Width: 6.0 Area: 48.0 Perimeter: 28.0
Rectangle 1: Length: -4.0 Width: 2.0 Area: 8.0 Perimeter: 12.0 Rectangle 2: Length: 8.0 Width: 6.0 Area: 48.0 Perimeter: 28.0
2 points
QUESTION 4
-
In the following code, which lines make up all of the accessor methods? 0 public class Bus { 1 private BankAccount ba; 2 private double fuelLeft; 3 private final double FUEL_MAX = 40.0; 4 private final double FUEL_COST = 3.54; 5 public Bus(BankAccount baRef) { 6 fuelLeft = 0; 7 ba = baRef; 8 } 9 public void fillTank() { 10 double cost = (FUEL_MAX - fuelLeft) * FUEL_COST; 11 if (ba.pay(cost) == true) { 12 fuelLeft = FUEL_MAX; 13 } 14 } 15 public double getFuelLeft() { 16 return fuelLeft; 17 } 18 }
Lines 9-14
Lines 15-17
Lines 9-17
Lines 5-8
2 points
QUESTION 5
-
Which of the following is NOT an example of a best practice?
Using an Application Programming Interface (API)
Using inheritance
Using accessor methods
Using the Model-View-Controller design pattern
2 points
QUESTION 6
-
Variables whose scope is the entire class are called instance variables.
True
False
2 points
QUESTION 7
-
Which Java keyword forces all subclasses to create their own version of, or override, the method?
abstract
model
template
frame
2 points
QUESTION 8
-
Design patterns are just another name for best practices.
True
False
2 points
QUESTION 9
-
To use an inherited method, an object must be cast to the superclass before using that method.
True
False
2 points
QUESTION 10
-
The following HTML code is most likely in which tier of the Model-View-Controller design pattern?
Circles Program Calculates Area and Perimeter of Circles
Enter the radius:
Model
View
Controller
Unable to determine
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started