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
Fill in the blank in the comment for this method header. /**
Gets the interest for the bank account
_________________________________
*/
Public double getInterest()
) . .
(Multiple Choice)
4.9/5
(37)
Given the following constructor for the BankAccount class, what output is generated by a call to new BankAccount()?
Public BankAccount()
{
System.out.println(balance);
}
(Multiple Choice)
4.9/5
(41)
What contains the instructions to initialize the instance variables of an object?
(Multiple Choice)
4.8/5
(25)
Consider the following method header for an Employee class: public void raiseSalary(double percentRaise)
{
______________________________________
}
Fill in the blank in the method body:
(Multiple Choice)
4.8/5
(38)
Information hiding makes it simpler for the implementor of a class to _____.
(Multiple Choice)
4.8/5
(28)
What statement is used to specify the value that a method gives back to its caller?
(Multiple Choice)
4.8/5
(39)
The use of an instance variable name inside a method denotes the instance variable of what?
(Multiple Choice)
4.8/5
(41)
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.9/5
(38)
If the CarComponent class had the call below added to it, where will car3 be placed?
Int y3 = (getHeight() - 30)/2;
Car car3 = new Car(0, y3);
Car3.draw(g2);
(Multiple Choice)
4.7/5
(40)
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 codeSystem.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)
4.8/5
(38)
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;
}
What should the body of the constructor be?
(Multiple Choice)
4.8/5
(29)
Identify the explicit parameter of the withdraw method of the BankAccount class.
(Multiple Choice)
4.7/5
(39)
Consider the following method header for the BankAccount class: public void addInterest(double rate)
{
______________________________________
}
Fill in the blank in the method body.
(Multiple Choice)
5.0/5
(32)
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 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 …
Which of the constructor specifications below will allow this code to behave as desired?
(Multiple Choice)
4.7/5
(40)
Choose the method header that goes with this method comment. /**
Raises the salary of the employee
@param percentRaise salary percentage raise
*/
(Multiple Choice)
4.9/5
(37)
Instance variables that are object references are initialized to what default value?
(Multiple Choice)
4.8/5
(45)
Assume the method below has been added to the BankAccount class. public void transfer (BankAccount source, double amount)
{
Balance = balance + amount;
Source.balance = source.balance - amount;
}
What will be output from the following statements that use the revised BankAccount class?
BankAccount first = new BankAccount (100.0);
BankAccount second = new BankAccount (300.0);
First.transfer (second, 50.0);
System.out.println (first.getBalance() + " "
+ second.getBalance());
(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 basic framework of a date class is below: public class Date
{
Private int day;
Private int month;
Private int year;
}
The default date will be set to January 1, 1990. What should the body of the constructor with zero parameters be?
(Multiple Choice)
4.8/5
(30)
Showing 61 - 80 of 103
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)