Exam 3: Implementing Classes
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
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)
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)
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)
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
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)