Exam 3: Implementing Classes

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

What is the process of hiding object data and providing methods for data access called?

(Multiple Choice)
4.9/5
(31)

Which of the following corresponds to the constructor body for a Square class that accepts an initial side length value where the instance variable is named sideLength?

(Multiple Choice)
4.8/5
(39)

You should declare all instance variables as ___.

(Multiple Choice)
4.8/5
(31)

Consider the constructor of the BankAccount class that has a parameter for the initial balance. Which line of code is equivalent to this constructor body? balance = initialBalance;

(Multiple Choice)
4.8/5
(37)

An instance variable declaration consists of which of the following parts?

(Multiple Choice)
4.8/5
(47)

Fill in the blank in the following method comment. /** Deposits money into the bank account @param _________ the amount to deposit */ Public void deposit(double amount) { Balance = balance + amount; }

(Multiple Choice)
4.8/5
(35)

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 basic framework of a date class is below: public class Date { Private int day; Private int month; Private int year; } We want to create a specific date using code like: Date first = new Date (16, 3, 2014); // Creates March 16, 2014 Date second = new Date (1, 9, 2013); // Creates September 1, 2013 Which of the constructor specifications below will allow this code to behave as desired?

(Multiple Choice)
4.9/5
(36)

A method is invoked on what type of parameter?

(Multiple Choice)
4.9/5
(39)

Given this method comment, fill in the blank in the method implementation. /** Gets the current balance of the bank account @return the current balance */ Public double getBalance() { __________ balance; }

(Multiple Choice)
4.8/5
(44)

Documentation ___ can be used to describe the classes and public methods of programs.

(Multiple Choice)
4.7/5
(39)

We want to change the BankAccount class so that all accounts will have a monthly fee. When a BankAccount is created, its monthly fee is set and cannot be changed. Which of the following will properly define the instance variable monthlyFee that holds the monthly fee?

(Multiple Choice)
4.9/5
(40)

Assuming the following code is the body of the main method, what output is generated? BankAccount myAccount; System.out.println(myAccount.getBalance());

(Multiple Choice)
4.8/5
(42)

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

(Multiple Choice)
4.7/5
(40)

Assume the method below has been added to the BankAccount class. public void giveBonus () { Balance = balance + 5.0; } What will be output from the following statements that use the revised BankAccount class? BankAccount premiumAccount = new BankAccount (100); PremiumAccount.giveBonus (); PremiumAccount.giveBonus (); PremiumAccount.giveBonus (); System.out.println (premiumAccount.getBalance());

(Multiple Choice)
4.7/5
(42)

When a method exits, its ____ are removed.

(Multiple Choice)
5.0/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: public class GeometricSequence { Private double initialValue; Private double multiplier; } What should the body of the constructor be?

(Multiple Choice)
4.9/5
(37)

Consider the following code fragment from the Italian Flag program in How To 3.2: public class ItalianFlagComponent { Public void paintComponent(GraphicsG) { Graphics2D g2 = (Graphics2d) g; ItalianFlag flag = new ItalianFlag(100, 100, 90); Flag.draw(g2); } } Which of the following statements is true?

(Multiple Choice)
4.8/5
(42)

What will be output from the following statements that use BankAccount class? BankAccount first = new BankAccount (100); BankAccount second = new BankAccount (100); BankAccount third = first; First.deposit (50.0); Second.deposit (50.0); Third.deposit (50.0); System.out.println (first.getBalance() + " " + second.getBalance() + third.getBalance());

(Multiple Choice)
4.9/5
(37)

Encapsulation allows a programmer to use a class without having to know its ____.

(Multiple Choice)
4.9/5
(38)

The black boxes from which a program is manufactured are called ___.

(Multiple Choice)
4.8/5
(47)
Showing 21 - 40 of 103
close modal

Filters

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