Exam 3: Implementing Classes

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

What is the return type of a constructor?

(Multiple Choice)
4.9/5
(40)

Which of the following is an instance variable of the CashRegister class?

(Multiple Choice)
4.9/5
(34)

Which of the following declares a sideLength instance variable for a Square class that stores an integer value?

(Multiple Choice)
4.9/5
(38)

What do static variables belong to?

(Multiple Choice)
4.8/5
(44)

Consider the following method comment and method header: /** Converts from a source measurement to a target measurement. __________ fromMeasurement the measurement @return the input value converted to the target unit */ Public double convertTo(double fromMeasurement) { . . . } Fill in the blank.

(Multiple Choice)
4.9/5
(37)

Which of the following denotes the implicit parameter?

(Multiple Choice)
4.9/5
(38)

What is the name of the parameter variable of the recordPurchase method of the CashRegister class?

(Multiple Choice)
4.8/5
(36)

What is a parameter variable?

(Multiple Choice)
4.8/5
(34)

A method header consists of which of the following parts?

(Multiple Choice)
4.7/5
(41)

If a method has two parameters, one explicit and one implicit, and a return type of void, then the documentation comments should include:

(Multiple Choice)
4.7/5
(46)

Private instance variables ___.

(Multiple Choice)
4.8/5
(38)

We want to create a class that represents a geometric sequence. A geometric sequence is a sequence of numbers that begin at some value and then multiplies each value by some constant to get the next value. For example, the geometric sequence 1, 2, 4, 8, 16 starts at 1 and multiplies each term by 2 to get the next. The geometric sequence 10.8, 5.4, 2.7, 1.35 starts at 10.8 and multiplies each term by 0.5 to get the next. The basic framework of a geometric sequence class is below: public class GeometricSequence { Private double initialValue; Private double multiplier; } We want to produce elements of the geometric sequence using code like: System.out.println (first.next()); // Prints 1 and advances System.out.println (first.next()); // Prints 2 and advances System.out.println (first.next()); // Prints 4 and advances System.out.println (first.next()); // Prints 8 and advances System.out.println (second.next()); //Prints 10.8 and advances System.out.println (second.next()); //Prints 5.4 and advances System.out.println (second.next()); //Prints 2.7 and advances Which of the method specifications below will allow this code to behave as desired?

(Multiple Choice)
4.7/5
(36)

Which of the following corresponds to the getArea method header for a Square class assuming an integer value for a side length?

(Multiple Choice)
4.9/5
(35)

What verifies that a class works correctly in isolation, outside a complete program?

(Multiple Choice)
4.9/5
(36)

Complete the following tester program by choosing the line that prints the expected outcome. public class BankAccountTester { Public static void main(String[] args) { BankAccount account = new BankAccount(1000); Account.deposit(account.getBalance()); System.out.println(account.getBalance()); ___________________ } }

(Multiple Choice)
4.8/5
(42)

What do parameters and local variables belong to?

(Multiple Choice)
4.8/5
(31)

What is a tester class?

(Multiple Choice)
4.8/5
(36)

What are the operations that any programmer can use to create and manipulate objects of the class called?

(Multiple Choice)
4.9/5
(39)

Choose the method header that goes with this method comment. /** Gets the salary of the employee @return the salary of the employee */

(Multiple Choice)
4.8/5
(42)

Consider the following invocation of the deposit method: mySavings.deposit(250); What is the implicit parameter?

(Multiple Choice)
4.9/5
(35)
Showing 81 - 100 of 103
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)