Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Which describe a design in which B is a derived class of base class A? (Check all that apply.) A Class A is Building

1. Which describe a design in which B is a derived class of base class A? (Check all that apply.)

A

Class A is Building that shelters people and equipment.

Class B is a CityVisualizer which will render one or more Buildings in 3D on a computer or smart phone screen.

B

Class A is Building that shelters people and equipment.

Class B is a HighRise, which has a minimum of five floors (stories) with stairs and elevators and utilized by government agencies, condo complexes and companies.

C

Class A is an AutoPart which goes into a car or truck. It has a part number, weight and price.

Class B is a FuelInjector, a special kind of part that goes into cars and trucks.

D

Class A is an AutoPart which goes into a car or truck. It has a part number, weight and price.

Class B is a Automobile -- either a Car or a Truck.

2.

In which type of class methods is it typically necessary to filter bad arguments (either directly or indirectly with the help of validators) in order to protect private data of your class?

A A set() method (non-constructor mutator).
B A display() (or show()) method, which takes no parameters, intended to output the data of the class for the display.
C A constructor that takes parameters.
D A get() method (non-constructor accessor).
E

A default constructor that takes no parameters.

3. Which of the following are good candidates for instance variables for a class that you would define?

A Variables (like loop counters or temporary variables) used by most or all of your instance methods (in an attempt to avoid redeclaring these variables multiple times as locals for each instance method).
B Private data whose values could be different for different objects of the class.
C Constants used by the class and the client.
D

Variables whose values are shared by all class objects.

4.

A linear search algorithm is written (as in the modules, for example) which searches an array for some user-defined value, clientData. If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules). Assume the array to be searched has 100 data elements in it. (Check all that apply):

[NOTE: due to common off-by-one interpretations when counting such things, if your predicted answer is within one (+1 or -1) of a posted option below, you can assume your prediction and the choice you are looking at are equivalent and check that option.]

a It might return to the client with an answer after only one comparison of data.
b It will never require more than 100 comparisons of data before it returns.
c It may require as many as 100 comparisons of data before it returns.
d It will always return with an answer in 50 or fewer comparisons of data.
e

It will always return with an answer in 10 or fewer comparisons of data.

5.

Assume that we have defined an enum type Planet and an instance memberMethod(), both in class SolarSystem:

class SolarSystem { public enum Planet { MERCURY, VENUS, EARTH, MARS, JUPITER, SATURN, URANUS, NEPTUNE } void memberMethod() { ... } } 

Also assume, as usual, that, a totally separate and unrelated class, Foothill, contains the client main().

Which statements have enum-related compiler errors? Assume that these are isolated statements in otherwise sensible, error-free programs and that there are no variables with the names MERCURY,... NEPTUNE anywhere in our program other than the ones seen above.

(There may be more than one correct choice.)

 A public static void main(String[] args) { Planet myHome; myHome = Planet.VENUS; }
 B public void memberMethod() { Planet myHome = EARTH; }
 C public static void main(String[] args) { SolarSystem.Planet myHome; myHome = SolarSystem.Planet.VENUS; }
D public void memberMethod() { Planet myHome = Planet.NEPTUNE; }
 E public static void main(String[] args) { SolarSystem sol = new SolarSystem(); sol.memberMethod(); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

6. Describe to a manager the different types of distance learning.

Answered: 1 week ago