Exam 3: Implementing Classes

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

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

(Multiple Choice)
4.8/5
(37)

Instance variables that are numbers are initialized to what default value?

(Multiple Choice)
4.9/5
(35)

Where do parameters and local variables belong?

(Multiple Choice)
4.9/5
(39)

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 currentvalue; private double multiplier; } We want to create a geometric sequence using code like: Geometricsequence first = new Geometricsequence (1,2); // Creates 1, 2, 4, 8, 16... Geometricsequence second = new Geometricsequence (10.8,0.5); / / Creates 10.8,5.4,2.7,1.35 ... We want to produce elements of the geometric sequence using code 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 What should the body of the next method be?

(Multiple Choice)
5.0/5
(38)

What is the return type of a constructor?

(Multiple Choice)
4.8/5
(35)

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
(49)

Consider the following code fragment from the Italian Flag program in How To 3.2: Consider the following code fragment from the Italian Flag program in How To 3.2:   Which of the following statements is true? Which of the following statements is true?

(Multiple Choice)
4.8/5
(40)

The use of an instance variable name inside a method denotes the instance variable of what?

(Multiple Choice)
4.8/5
(33)

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

(Multiple Choice)
4.9/5
(34)

When you declare a method, you also need to provide the method ____, which consists of statements that are executed when the method is called.

(Multiple Choice)
4.8/5
(39)

Which statement describes a central benefit of information hiding?

(Multiple Choice)
4.8/5
(39)

Which special delimeter is used with the javadoc utility to document method arguments?

(Multiple Choice)
4.9/5
(38)

A class declaration consists of which of the following parts?

(Multiple Choice)
4.8/5
(42)

Identify the explicit parameter of the withdraw method of the BankAccount class.

(Multiple Choice)
4.8/5
(37)

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: 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:   Which of the constructor specifications below will allow this code to behave as desired? Which of the constructor specifications below will allow this code to behave as desired?

(Multiple Choice)
4.8/5
(42)

We want to create a class that represents a date.A date has a day, month, and year.For example, the date March 16, 2014 has the day 16, month 3, and year 2014.The parameter variables in the constructor for month, day, and year should be m, d and y.The basic framework of a date class is below: public class Date { private int day; private int month; private int year; } What should the body of the constructor be?

(Multiple Choice)
4.8/5
(36)

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

(Multiple Choice)
4.8/5
(35)

Each object of a class has its own set of ___.

(Multiple Choice)
4.7/5
(45)

Consider the following method header for the BankAccount class: Consider the following method header for the BankAccount class:   Fill in the blank in the method body. Fill in the blank in the method body.

(Multiple Choice)
4.8/5
(33)

Which of the following statements is true about constructors?

(Multiple Choice)
4.8/5
(31)
Showing 21 - 40 of 108
close modal

Filters

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