Exam 3: Implementing Classes

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

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

Free
(Multiple Choice)
4.9/5
(40)
Correct Answer:
Verified

C

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. The instance variable monthlyFee will hold the monthly fee. Which of the following methods deducts the value of the monthly fee from the account?

Free
(Multiple Choice)
4.7/5
(47)
Correct Answer:
Verified

A

A class declaration consists of which of the following parts?

Free
(Multiple Choice)
4.9/5
(38)
Correct Answer:
Verified

A

What is the name of the constructor for the BankAccount class?

(Multiple Choice)
4.9/5
(35)

Assuming the following code is the body of the deposit method, what output is generated by the valid call myAccount.deposit(1000) for an account with an initial balance of 500? public void deposit(double amount) { System.out.println(amount); Double newBalance = balance + amount; Balance = newBalance; }

(Multiple Choice)
4.9/5
(28)

What is the return type of the println method of the PrintStream class?

(Multiple Choice)
4.9/5
(31)

You should provide documentation comments for ___.

(Multiple Choice)
4.7/5
(39)

When are instance variables initialized?

(Multiple Choice)
4.9/5
(38)

Consider the following code to declare a constructor for the Player class: public void Player(String playerName) { Name = playerName; } Which statement is true?

(Multiple Choice)
4.7/5
(31)

Which statement is true about the following constructor of the BankAccount class? public BankAccount(double balance) { This.balance = balance; }

(Multiple Choice)
4.8/5
(40)

When drawing complex shapes, provide a(n) ____ to set the position of the shape.

(Multiple Choice)
4.9/5
(45)

Which of the following statements is true about constructors?

(Multiple Choice)
4.7/5
(29)

Which of the following corresponds to the getArea method body for a Square class where the instance variable is named sideLength?

(Multiple Choice)
4.8/5
(26)

Which of the following corresponds to a valid constructor header for the Player class?

(Multiple Choice)
4.8/5
(37)

What is the name of the local variable of the giveChange method of the CashRegister class?

(Multiple Choice)
4.9/5
(31)

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

(Multiple Choice)
4.9/5
(42)

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

(Multiple Choice)
4.9/5
(40)

What contains the instructions to initialize the instance variables of an object?

(Multiple Choice)
4.7/5
(48)

What do instance variables belong to?

(Multiple Choice)
4.8/5
(30)

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

(Multiple Choice)
4.8/5
(41)
Showing 1 - 20 of 103
close modal

Filters

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