subject

1,

Part of the Throttle implementation from Chapter 2 is shown below. Match each method with the correct classification.
public class Throttle
{
public Throttle(int size)...
public double getFlow( )...
public boolean isOn( )...
public void shift(int amount)...
public void shutOff( )...
}
Answer

-A. B.C.
public Throttle(int size)...
-A. B.C.
public double getFlow( )...
-A. B.C.
public boolean isOn( )...
-A. B.C.
public void shift(int amount)...
-A. B.C.
public void shutOff( )...

2.
What is the common pattern of class definitions that is used in Chapter 2?
Answer
A.
Methods and instance variables are both private.
B.
Methods are private, and instance variables are public.
C.
Methods are public, and instance variables are private.
D.
Methods and instance variables are both public.
3.Here is part of the Throttle declaration

public class Throttle
{
public Throttle(int size) ...
public double getFlow() ...
public void shift(int amount) ...
}

Write several lines of Java code to create a Throttle called quiz with 100 positions, activate the method that shifts quiz's flow to the halfway
point, and then print the current flow from quiz.

Answer
A.
Accessor method
B.
Constructor
C.
Modification method
4,

Suppose that the Foo class does not have a clone method. What happens when an assignment x=y; is given for two Foo objects?
Answer

A.
x is set to refer to a copy of y's object
B.
x is set to refer to the same object that y refers to
C.
Compiler error
D.
Run-time error
5.
Suppose I create two Throttles using the class from Chapter 2:
Throttle mower = new Throttle(...);
Throttle copter = new Throttle(...);

Which statement best describes the instance variable called top for these two Throttles?
Answer
A.
mower. top and copter. top will always be two separate instance variables.
B.
mower. top and copter. top will only be separate if the two throttles are created with a different number of positions.
C.
mower. top and copter. top will never be two separate instance variables.
6.
Here is a small function that uses the Bag class from Chapter 3:

public static void quiz( )
{
int i; // Line 1
IntArrayBag b = new IntArrayBag( ); // Line 2
b. add(42); // Line 3
i = b. size( ); // Line 4
System. out. println(i); // Line 5
}
When is the Bag's array created?
Answer
A.
During the execution of Line 2.

B.
During the execution of Line 3.

C.
Just after Line 4 and before line 5.

D.
After Line 5.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
All of the following are characteristics that must be contained in any knowledge representation scheme except
Answers: 3
question
Computers and Technology, 22.06.2019 18:30
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Write and test a python program to find and print the largest number in a set of real (floating point) numbers. the program should first read a single positive integer number from the user, which will be how many numbers to read and search through. after reading in all of the numbers, the largest of the numbers input (not considering the count input) should be printed.
Answers: 1
question
Computers and Technology, 24.06.2019 20:30
How is energy expended in active transport
Answers: 1
You know the right answer?
1,

Part of the Throttle implementation from Chapter 2 is shown below. Match each method...
Questions
question
Mathematics, 18.04.2021 15:50
question
English, 18.04.2021 15:50
question
Mathematics, 18.04.2021 15:50
question
English, 18.04.2021 15:50