What is a product sunset, and what is involved?


What is a product sunset, and what is involved?


Answer: Product sunset is the process of withdrawing the software from the market.
However, existing software users’ support can not be abruptly halted. Thus there is a period of post sunset support where no new features are added but only the major functional problems are fixed to keep the users operational.
This extended support usually lasts for a short period of time after sunset unless some organization steps in to support the users and customers for a fee and converts the support into a support “business.”

What is a pre-requisite/co-requisite relationship of product maintenance and fix releases?


What is a pre-requisite/co-requisite relationship of product maintenance and fix releases?


Answer: There are times, a software S1 fix release also requires a fix release of another software S2 because S1 and S2 are related.
An example may be where a change in S1 application requires an additional modification of a feature in S2.  In this case the two software S1 and S2 modifications may be considered as co-requisites that must be released together or S2 modification is a pre-requisite that must be available first before S1 change may be released.

What is a problem priority level and what is it used for?


What is a problem priority level and what is it used for?


Answer: A problem priority level is a metric that gauges and categorizes the severity level of a reported software problem.
It is used to prioritize the problem fixing task and provide a rough estimate of problem fix-response time to the customer.

Explain the customer problem arrival curve in terms of customer usage of the product and fixes.


Explain the customer problem arrival curve in terms of customer usage of the product and fixes.


Answer: Customer problem arrival rate is directly related to the customer problem discovery rate.  The rate of customer problem discovery is proportional to the amount of usage the software is experiencing.
For example, a new software that has not been run often will not have much usage-time and the discovery of software problems will be relatively low. As the usage-time increases, the discovery of defects increases accordingly. After a period of time, the discovered problems will be fixed and all the major areas of software would have been exercised. Thus the discovery rate of defects will once again become low after a period of heavy usage and problem fixes.
The graphical curve of this rise of problem discovery and problem arrival on the Y-axis with increase in usage-time (on the X-axis) followed by a gradual decrease of problem discovery (the Y-axis) may be modeled with a Rayleigh curve.

Who is responsible for the Support FAQ database?


Who is responsible for the Support FAQ database?


Answer: The Support FAQ database is updated with problem descriptions by the customer support representatives who accept reported new problems.
As the problems are fixed or closed, the problem/fix analysts update the Support FAQ database with fix and problem closure status descriptions.
The over-all database integrity, security, performance, etc. is still handled by a data base administrator.

List three customer support functions that a customer support/service organization performs.


List three customer support functions that a customer support/service organization performs.


Answer: There are many customer support functions performed by support/service organization; some of the more common ones include
1) taking/recording/checking the name and identification of customer to ensure that the person is a legitimate customer,
2) listen to and record the problem,
3) answer the question if the solution is known or search the FAQ database for an answer, include providing an expected fix date if the problem is yet unresolved.

Why do we need to have change control?


Why do we need to have change control?


Answer: If we do not have change control, problems dealing with scope creep such as schedule and resource expansion will affect the support/service organization - just as these problems affect normal development organization.

Describe the steps involved when a customer problem is passed from the customer service/support representative to the technical problem/fix analyst until the problem is resolved.


Describe the steps involved when a customer problem is passed from the customer service/support representative to the technical problem/fix analyst until the problem is resolved.


Answer: There are several steps involved and they are summarized as follows.

a) problem description and related information is summarized in a problem report and submitted to the problem/fix group;
b) the problem/fix analyst will explore and analyze the problem;
c) the problem/fix analyst will then accept or reject the problem based on the analysis;
d) if the problem is rejected then the customer support representative is notified; otherwise, the problem is accepted, a change request is generated and the problem enters a fix cycle of design/code/test;
e) the fix may be individually packaged and immediately released or may be integrated into a fix-release package, depending on the problem priority level;
f) the support FAQ database is then updated to reflect the closure status of this problem.

What are the check-in and check-out activities in configuration management?


What are the check-in and check-out activities in configuration management?


Answer: Check-in refers to storing or returning an artifact to a configuration management’s library while check-out refers to retrieving an artifact from the configuration management’s library.

What is the storage and access model component of configuration management?


What is the storage and access model component of configuration management?


Answer: To help configuration management carry out its policies, the pieces and parts of different artifacts must be stored and be retrieved.
The storage and access model describes and defines the capabilities to store and control the access of these artifacts, usually through an automated library.

If the release number is part of the naming model and the software product planned life cycle is no more than 100 releases, then how many numerical position need to be reserved in the naming model for identifying the release number?


If the release number is part of the naming model and the software product planned life cycle is no more than 100 releases, then how many numerical position need to be reserved in the naming model for identifying the release number?


Answer: Two positions for release numbers 00 through 99 to identify 100 releases.

What is configuration management and why is a naming model needed?


What is configuration management and why is a naming model needed?


Answer: Configuration management is a process or a framework of activities, with possibly automated tools, used to manage the various artifacts needed in developing and supporting a software product.
A naming model is needed for configuration management in order to uniquely identify and control the pieces and parts of the artifacts.

What are the four major activities that make up configuration management?


What are the four major activities that make up configuration management?


Answer: These are:
a) understand and agree on organization’s policies, process activities, and the resulting artifacts that need to be managed,
b) determine and define the framework that needs to be used to manage the artifacts,
c) determine and bring in any tool that is needed to facilitate the management, and
d) train and ensure that the agreed upon configuration management process is practiced and adhered to.

If the configuration management includes the tracing and relating of different types of artifacts such as requirements to test cases, give an example of what we would need in our naming model.


If the configuration management includes the tracing and relating of different types of artifacts such as requirements to test cases, give an example of what we would need in our naming model.


Answer: There needs to be field in the naming model to identify the type of artifact such as design or test.
There also need to be fields in the naming model to identify the release and version that these artifacts jointly belong.

Describe the major difference between the “view” and the “modify” functions in the storage and access model.


Describe the major difference between the “view” and the “modify” functions in the storage and access model.


Answer: The “view” function is the retrieval of an artifact for the purpose of reading the artifact and may be performed by all at all times.
The “modify” function is the retrieval of an artifact for the purpose of making changes to the artifact.
Thus in the case of modify, only those authorized should be allowed to perform the function. In addition, to prevent conflicts, when an artifact X is retrieved for modification, that X is locked from other modify functions until it is returned. X may still be viewed by others.

List three concerns you may need to look into prior to deciding on a configuration management tool.


List three concerns you may need to look into prior to deciding on a configuration management tool.


Answer: There are many concerns and they should include these:
a) is the tool easy to learn and what kind of education is provided by the tool vendor,
b) does the tool have all the needed functionalities to accommodate the organization’s naming model and access model and
c) can the tool accommodate geographically separate, multi-site development and support.

What is a software system build process?


What is a software system build process?


Answer: Software system build is a set of activities where all the software source code and data artifacts are gathered for compilation into executables.
All the cross references and external names are resolved.
The complete set of artifacts are compiled and linked together into an executable.

Describe the notion of “promotion” of artifacts used in configuration management.


Describe the notion of “promotion” of artifacts used in configuration management.


Answer: In managing the development and testing of artifacts, it is important to lock those artifacts that have achieved certain level of completion to prevent the artifact from any change and possibly regressing.
All the artifacts that have reached the same level of achievement, such as completing functional test, is moved and locked at that level, say level “x.”
This joint moving and locking at level “x “ is called “promoting to level x.”

Explain the difference between Black-box testing and White-box testing.


Explain the difference between Black-box testing and White-box testing.


Answer: Black-box testing only considers the output compared to the expected output without consideration of the actual code processing.

White-box testing examines the internal code.  Programmers use this methodology when using the debugger, placing breakpoints in the code, and/or examining the internal memory of the variables.

What is the difference between performance testing and stress testing?


What is the difference between performance testing and stress testing?


Answer: In performance testing, the software is tested against the performance requirements set by the requirements (e.g. x number of transactions/minute).

In stress testing, the software is tested to see how and when it degrades beyond the performance criteria set by the requirements.

Briefly explain two different ways to decide when to stop testing.


Briefly explain two different ways to decide when to stop testing.


Answer: One way is to use the ratio of seeded errors and real errors to discovered seeded errors to discovered real errors to project or estimate the number of real errors that may still be left. Use that estimate to decide if testing may be stopped.

Another way is to observe the problem discovery rate and the accumulative number of problems discovered. As the accumulative problem discovered start to level off, then one may start to consider stop testing.

Describe the steps involved in a formal inspection process and the role of a moderator in the inspection.


Describe the steps involved in a formal inspection process and the role of a moderator in the inspection.


Answer: Inspection process goes through several steps:

-    Planning for the inspection
-    Presentation of the overview of the work product to be inspected
-    Preparation for the inspection by the inspectors
-    Examining or inspecting the material
-    Rework of the defective areas in material
-    Follow-up and close out

Moderator is an important person that is appointed during the planning stage.      He/she will ensure that the inspection process is followed. Moderator also presides over the actual examination of the material and act as the adjudicator whenever necessary.

Describe the steps involved in a formal inspection process and the role of a moderator in the inspection.


Describe the steps involved in a formal inspection process and the role of a moderator in the inspection.


Answer: Inspection process goes through several steps:

-    Planning for the inspection
-    Presentation of the overview of the work product to be inspected
-    Preparation for the inspection by the inspectors
-    Examining or inspecting the material
-    Rework of the defective areas in material
-    Follow-up and close out

Moderator is an important person that is appointed during the planning stage.      He/she will ensure that the inspection process is followed. Moderator also presides over the actual examination of the material and act as the adjudicator whenever necessary.

Briefly explain the concept of static analysis and to which software artifacts it can be applied.


Briefly explain the concept of static analysis and to which software artifacts it can be applied.


Answer: Static analysis, as reviews and inspections, examines the static structures of executables and non-executables with the aim of detecting errors and error-prone conditions. Some of the artifacts that static analysis applies are:
-    intermediate documents such as design document
-    source code
-    executable files

Explain how to start Black-box testing and discuss with regards to Unit testing and Functional testing.


Explain how to start Black-box testing and discuss with regards to Unit testing and Functional testing.


Answer: Black-box testing starts in the Unit testing where the programmer tests a single unit of the system in isolation.  Once a group of units that all serve a functional purpose have been unit tested then a functional test is done of the group with the black box methodology.

Discuss the difference in test cases using Equivalence Class Partitioning.


Discuss the difference in test cases using Equivalence Class Partitioning.


Answer: The software engineer studies the proposed system for differences.  For example, positive, zero, and negative values may be in separate classes with different behaviors and results.
The textbook shows different age groups that result in different groups.  This is Equivalence Class Partitioning.
Instead of testing every possible age (which is problematic) consider if the system has different groups and focus to test each of the different groups to discover defects in each of the groups’ processing.

In code inspection, what would you set as the condition for re-inspection?


In code inspection, what would you set as the condition for re-inspection?


Answer: Both the number of problems found and the severity of the problems found would be used as criteria for re-inspection of any code.
Possibly, the past history of the particular programmer whose work has been inspected could also add to the criteria.

Consider the simple case of testing 2 variables, X and Y, where X must be a non-negative number and Y must be a number between -5 and +15. Utilizing boundary analysis, list the test cases.


Consider the simple case of testing 2 variables, X and Y, where X must be a non-negative number and Y must be a number between -5 and +15. Utilizing boundary analysis, list the test cases.


Answer: Assuming that the variables X and Y are independent, then:

For variable X:  we would have a test case for below boundary, -2.4, at the boundary, 0, and within the boundary, +200.78.

For variable Y:  we would have a test case for below the boundary, -7.3, at the lower boundary, -5, within the boundary 0, at the upper boundary, +15, and above the upper boundary, +1002.

List a few of the types of code comments described in the book.


List a few of the types of code comments described in the book.


Answer:
1. Repeat of the code;
2. explanation of the code;
3. marker in the code;
4. summary of the code;
5. description of the code intent;
6. external references.

What are glue tokens and super glue tokens, and which type contributes more to cohesion?


What are glue tokens and super glue tokens, and which type contributes more to cohesion?


Answer: Glue tokens are data tokens that lie in more than one data-slice, and super glue tokens are data tokens that lie in every data-slice. The super glue tokens contribute more to cohesion because they lie in every data slice.

What is software cohesion?


What is software cohesion?


Answer: Cohesion is a characteristic that describes the degree of relatedness within the software.

What is fan-in and fan-out, and what attribute do they measure?


What is fan-in and fan-out, and what attribute do they measure?


Answer: Fan-in is a measure of number of information flow into a module or component. Fan-out is the number of information flow out of a module.
An example of fan-in for module-x would be the number of modules that call module-x and for fan-out of module-x would be the number of modules that are called by module-x. Thus fan-in and fan-out measure the coupling attribute among modules.

What is software coupling?


What is software coupling?


Answer: Coupling is a characteristic that describes the degree of interdependence or interaction among the parts within the software.

What is the Law of Demeter attempting to achieve?


What is the Law of Demeter attempting to achieve?


Answer: Law of Demeter is a set of guiding rules that limits the span of control of an object by restricting the messaging structure among methods of a class. Through these restrictions it is conjectured that we can reduce coupling and enhance cohesion.

What is McCabe’s cyclomatic complexity number a) attempting to measure, and b) what is the cyclomatic complexity number of a program A that contains 3 binary predicates (or branches)?


What is McCabe’s cyclomatic complexity number a) attempting to measure, and b) what is the cyclomatic complexity number of a program A that contains 3 binary predicates (or branches)?


Answer:
a) McCabe’s cyclomatic complexity number measures the control flow complexity of software.
b) Using the simple formula of (#of binary branches + 1), the cyclomatic number of program A is (3+1) or 4.

List four out of the eight rules of user interface design identified by Shneiderman and Plaisant.


List four out of the eight rules of user interface design identified by Shneiderman and Plaisant.


Answer: There are actually 8: a) consistency, b) provide short cuts, c) informative feedback, d) closure in dialogues, e) simple error handling and prevention, f) permit “re-do”, g) support locus of control, h) reduce the amount of short-term memory needs. Any four of the eight would be fine.

What are the levels of coupling?


What are the levels of coupling?


Answer: There are 5 levels of coupling listed in the order of worst to best: content, common, control, stamp, and data.

What are the six design measurements of C-K metrics in OO?


What are the six design measurements of C-K metrics in OO?


Answer: They are a) weighted number of methods per class, b) depth of inheritance tree of the class, c) number of children of a class, d) coupling between objects, e) number of responses to a class message, and f) lack of cohesion among methods in a class

What is a program slice?


What is a program slice?


Answer: A program slice is the set of statements that can affect the value of some specified variable of interest in the program.

In contrast to general design, what is user interface design interested in?


In contrast to general design, what is user interface design interested in?


Answer: The general software design is concerned about the software components, their characteristics and their interactions. User interface design is focused on the interaction between the software and its human users; thus both software and human attributes are of concern in user interface design.

What are the levels of cohesion?


What are the levels of cohesion?


Answer: There are 7 levels of cohesion listed in the order of worst to best: coincidental, logical, temporal, procedural, communicational, sequential, and functional.

Explain how the Model-View-Controller architectural style is done using HTML-Script-SQL.


Explain how the Model-View-Controller architectural style is done using HTML-Script-SQL.


Answer: The Model-View-Controller (MVC) architectural style is done with HTML as the View of the system and SQL as a database.  The database has the model of the system.  PHP is the script used as the controller for the system.

What is the difference between low fidelity prototypes and high fidelity prototypes?


What is the difference between low fidelity prototypes and high fidelity prototypes?


Answer: Low fidelity prototypes are quick hand drawn screens using markers, post-it notes, post cards, and/or cut out images to represent the screens of the system.  Simple mockup sketch of the target product.
High fidelity prototypes are screens created using a tool to design the screens.  These screens look and mimic the behavior of the future screens of the system.  An example of a tool is visual basic with the use of hide and show. Detailed mockup resembling and behaving close to the final product.

Mention and describe three different views used in architectural design.


Mention and describe three different views used in architectural design.


Answer:
Architectural design is a high level view of the system. It can be described with:
-    logical view : represents the decomposition of a system and how those parts work with each other
-    physical architectural view: represents the mapping of the software to the hardware
-    process view: represents the run-time “processes” and flow of the system.

When we employ the technique of generalization in design, what are we doing, and which part of OO design is closely related to this concept?


When we employ the technique of generalization in design, what are we doing, and which part of OO design is closely related to this concept?


Answer: Generalization is an abstraction where we keep only the essentials and suppress the details. In OO, in moving from specific objects to a general class definition is an example of generalization.

Explain “Adding a course” from section 7.3.4 using Norman’s 7 Stage Model.


Explain “Adding a course” from section 7.3.4 using Norman’s 7 Stage Model.


Answer:
Form a goal – add Engl 2011 - The user (aStudent) forms the goal “I need to add Engl 2011 to my schedule”.
Form an intention – find Engl 2011 - The user (aStudent) forms the intention on the screen shown in 7.26 to find Engl 2011 in the drop box.
Specify the action – mouse can show courses in the drop box - The user will decide to use the mouse to click and hold open the drop box and move the mouse down until he/she sees the Engl 2011 course.
Execute the action - The user moves the mouse to the arrow in the drop box and clicks when he/she is on the arrow of the drop box.
Perceive the system state (feedback) – he/she sees the drop box open with multiple courses in a list.
Interpret the feedback – he/she sees the Engl 2011
Evaluate – because the user sees the course they evaluate “Success” to their intention.

Note: They would continue with the next intention to click “Add Course”.

What is the difference between data modeling and logical data base design?


What is the difference between data modeling and logical data base design?


Answer: In data modeling we are constructing and showing the Entity-Relationship among the objects.
In logical data base design, the E-R diagram is converted to the sets of tables and relationships among the tables.

Discuss Figure 7.26 with regard to the user’s interaction; the screen’s interaction; and the system’s interaction (process).


Discuss Figure 7.26 with regard to the user’s interaction; the screen’s interaction; and the system’s interaction (process).


Answer: The user sees the Registration Screen for the Spring 2012, using the drop box “All Courses” they would select a course and click the button “Add Course”.

The screen would show the representation seen at the top of Figure 7.26 initially.  This screen would react to the user’s usage of the drop box (showing a scrollable list of the available courses and showing the course selected). When the user has selected a course and clicked “Add Course” the screen would send the information to the registrationGUI and when the RegistrationGUI returns success it would show the second screen in Figure 7.26.
The system’s interaction shown in Figure 7.26 begins with the RegistrationGUI object passing the registration information to the aSection object.  This aSection object needs to check if the student has the prerequisites for the course.  If the boolean returned is True then the message Add(aStudent) is sent to students object. Note: another sequence diagram would represent Boolean = False.

What is the Viewpoint-Oriented Requirements Definition method used for?


What is the Viewpoint-Oriented Requirements Definition method used for?


Answer: This method is based on the understanding that requirements are not viewed the same by the different stakeholders. So this methodology of collecting requirements ensures that all different perspectives of requirements are provided.

List the 4 values listed in the agile software manifesto.


List the 4 values listed in the agile software manifesto. 


Answer:
1. Individuals and interactions over processes and tools;
2. Working software over comprehensive documentation;
3. Customer collaboration over contract negotiation;
4. Responding to change over following a plan

List characteristics of agile methods.


List characteristics of agile methods.


Answer: short releases and iterations; incremental design; user involvement; minimal documentation; informal communication; change.

List a at least 3 of the problems that may arise with traditional software processes.


List a at least 3 of the problems that may arise with traditional software processes.


Answer: Lengthy development times; inability to cope with changing requirements; assumptions that requirements are completely understood before the project begins; reliance on heroic developer effort; complex methodologies; waste/duplication of effort.

List disadvantages of agile processes.


List disadvantages of agile processes.


Answer: Possibly not scalable; heavy reliance on teamwork; reliance on frequent access to customer; cultural clash.

List at least 3 of the advantages of agile processes.


List at least 3 of the advantages of agile processes.


Answer:
1. Low process complexity;
2. low cost on overhead;
3. efficient handling of changes; fast results; usable systems.

How many process areas, in total, are included in SEI’s Software CMMI?


How many process areas, in total, are included in SEI’s Software CMMI?

List those that fall into the engineering category and the support category.


Answer: There are a total of 25 process areas in CMMI.

Those that fall into the Engineering category are:

1. Requirements Development
2. Requirements Management
3. Technical Solution
4. Product Integration
5. Verification
6. Validation

Those that fall into the Support category

1. Configuration Management
2. Process and Product Quality Assurance
3. Measurement and Analysis
4. Organizational Environment for Integration
5. Decision Analysis and Resolution
6. Causal Analysis and Resolution

Discuss one advantage and one disadvantage of the waterfall process.


Discuss one advantage and one disadvantage of the waterfall process.


Answer: An advantage is that it provided a clear way to track the stages of development for the project managers.  A disadvantage is that it provided very little task overlapping, is sequential, and is single iteration.

In a Spiral model, what are the four quadrants?


In a Spiral model,  what are the four quadrants?


Answer: The four quadrants are
i) plan next phase, ii) determine objectives, alternatives, and constraints, iii) evaluate alternatives, identify and resolve risks, and iv) develop, verify next level product

What is the goal of a software process model?


What is the goal of a software process model?


Answer: To provide guidance for a systematic way to coordinate and control the tasks that must be performed in order to achieve the end software product and the associated software project objectives.

What is an entry and exit criteria to a process?


What is an entry and exit criteria to a process?


Answer: Entry criteria describes and lists all the conditions and materials that must be met prior to starting a process or an activity. Exit criteria describes and lists all the conditions and materials that must be met prior to terminating a process or an activity.

The income and substitution effects account for:


The income and substitution effects account for: 

A. the upward sloping supply curve.
B. the downward sloping demand curve.
C. movements along a given supply curve.
D. shifts in the demand curve.

An increase in the price of a product will reduce the amount of it purchased because:


An increase in the price of a product will reduce the amount of it purchased because: 


A. supply curves are upsloping.
B. the higher price means that real incomes have risen.
C. consumers will substitute other products for the one whose price has risen.
D. consumers substitute relatively high-priced for relatively low-priced products.

A demand curve:


A demand curve:

A. shows the relationship between price and quantity supplied.
B. indicates the quantity demanded at each price in a series of prices.
C. graphs as an upsloping line.
D. shows the relationship between income and spending.

Economists use the term "demand" to refer to:


Economists use the term "demand" to refer to: 

A. a particular price-quantity combination on a stable demand curve.
B. the total amount spent on a particular commodity over a fixed time period.
C. an upsloping line on a graph that relates consumer purchases and product price.
D. a schedule of various combinations of market prices and amounts demanded.

The demand curve shows the relationship between:


The demand curve shows the relationship between: 

A. money income and quantity demanded.
B. price and production costs.
C. price and quantity demanded.
D. consumer tastes and quantity demanded.

Graphically, the market demand curve is:


Graphically, the market demand curve is: 

A. steeper than any individual demand curve that is part of it.
B. greater than the sum of the individual demand curves.
C. the horizontal sum of individual demand curves.
D. the vertical sum of individual demand curves.

The law of demand states that, other things equal:


The law of demand states that, other things equal: 

A. price and quantity demanded are inversely related.
B. the larger the number of buyers in a market, the lower will be product price.
C. price and quantity demanded are directly related.
D. consumers will buy more of a product at high prices than at low prices.

Markets, viewed from the perspective of the supply and demand model:


Markets, viewed from the perspective of the supply and demand model: 

A. assume many buyers and many sellers of a standardized product.
B. assume market power so that buyers and sellers bargain with one another.
C. do not exist in the real-world economy.
D. are approximated by markets in which a single seller determines price.

A market:


A market: 

A. reflects upsloping demand and downsloping supply curves.
B. entails the exchange of goods, but not services.
C. is an institution that brings together buyers and sellers.
D. always requires face-to-face contact between buyer and seller.

A fundamental difference between the command system and the market system is that, in command systems:


A fundamental difference between the command system and the market system is that, in command systems: 


A. the division of output is decided by central planning rather than by individuals operating freely through markets.
B. all economic decisions are made by the government, whereas there is no government in a market system.
C. scarcity does not exist, whereas it does in a market system.
D. money is not used, whereas it is in a market system.

Command systems are also known as:


Command systems are also known as: 

A. market systems.
B. pure capitalism.
C. laissez-faire capitalism.
D. communism.

Economic systems differ according to which two main characteristics?


Economic systems differ according to which two main characteristics? 

A. Who owns the factors of production, and the methods used to coordinate economic activity.
B. The technology used in production, and the quantity and quality of natural resources.
C. How goods are produced, and who gets them.
D. The political system in place, and the degree of scarcity facing the economy.

The term laissez-faire suggests that:


The term laissez-faire suggests that: 

A. land and other natural resources should be privately owned, but capital should be publicly owned.
B. land and other natural resources should be publicly owned, but capital should be privately owned.
C. government should not interfere with the operation of the economy.
D. government action is necessary if the economy is to achieve full employment and full production.

An economic system:


An economic system: 


A. requires a grouping of private markets linked to one another.
B. is a particular set of institutional arrangements and a coordinating mechanism used to respond to the economizing problem.
C. requires some sort of centralized authority (such as government) to coordinate economic activity.
D. is a plan or scheme that allows a firm to make money at some other firm's expense.

The French term "laissez-faire" means:


The French term "laissez-faire" means: 


A. "there is no free lunch."
B. "let it be."
C. "circular flow."
D. "public ownership."

Examples of command economies are:


Examples of command economies are: 


A. The United States and Japan.
B. Sweden and Norway.
C. Mexico and Brazil.
D. Cuba and North Korea.

The economic perspective entails:


The economic perspective entails:

 

A. irrational behavior by individuals and institutions.
B. a comparison of marginal benefits and marginal costs in decision making.
C. short-term but not long-term thinking.
D. rejection of the scientific method.

The study of economics is primarily concerned with:


The study of economics is primarily concerned with: 


A. keeping private businesses from losing money.
B. demonstrating that capitalistic economies are superior to socialistic economies.
C. choices that are made in seeking the best use of resources.
D. determining the most equitable distribution of society's output.

Economics may best be defined as the:


Economics may best be defined as the:

A. interaction between macro and micro considerations.
B. social science concerned with how individuals, institutions, and society make optimal choices under conditions of scarcity.
C. empirical testing of value judgments through the use of logic.
D. use of policy to refute facts and hypotheses.

A person should consume more of something when its marginal:


A person should consume more of something when its marginal:

 

A. benefit exceeds its marginal cost.
B. cost exceeds its marginal benefit.
C. cost equals its marginal benefit.
D. benefit is still positive.

Joe sold gold coins for $1000 that he bought a year ago for $1000. He says, "At least I didn't lose any money on my financial investment." His economist friend points out that in effect he did lose money, because he could have received a 3 percent return on the $1000 if he had bought a bank certificate of deposit instead of the coins. The economist's analysis in this case incorporates the idea of:


Joe sold gold coins for $1000 that he bought a year ago for $1000. He says, "At least I didn't lose any money on my financial investment." His economist friend points out that in effect he did lose money, because he could have received a 3 percent return on the $1000 if he had bought a bank certificate of deposit instead of the coins. The economist's analysis in this case incorporates the idea of: 


A. opportunity costs.
B. marginal benefits that exceed marginal costs.
C. imperfect information.
D. normative economics.

According to economists, economic self-interest:


According to economists, economic self-interest:

 

A. is a reality that underlies economic behavior.
B. has the same meaning as selfishness.
C. is more characteristic of men than of women.
D. is usually self-defeating.

For economists, the word "utility" means:


For economists, the word "utility" means: 

A. versatility and flexibility.
B. rationality.
C. pleasure or satisfaction.
D. purposefulness.

To indicate a word is slang or informal usage,:


To indicate a word is slang or informal usage,:


A. enclose it in quotation marks.
B. explain it in parentheses.
C. underline it.
D. None of these; do not use slang or informal terms.

Identify the sentence that is punctuated correctly.


Identify the sentence that is punctuated correctly.


A. The operating costs, as he probably told you, are too high.
B. The operating costs, as he probably told you are too high.
C. The operating costs as he probably told you, are too high.
D. The operating costs as he probably told you are too high.

The main use of brackets in writing is to:


The main use of brackets in writing is to:


A. mark an interruption in a quotation.
B. note an error in a quotation.
C. indicate an omission from a quotation.
D. indicate an alteration in a quotation.

Which of the following is NOT true?


Which of the following is NOT true?


A. Always capitalize specific brand names.
B. Capitalize names of specific places.
C. Capitalize common nouns.
D. Capitalize proper nouns.

Identify the correct sentence.


Identify the correct sentence.

A. The River in Hackensack, New Jersey overflowed during Hurricane Sandy.
B. The river in Hackensack, NJ overflowed during hurricane sandy.
C. The river in Hackensack New Jersey, overflowed during Hurricane Sandy.
D. The river in Hackensack, New Jersey, overflowed during Hurricane Sandy.

Identify the sentence that is punctuated correctly.


Identify the sentence that is punctuated correctly.


A. These products may not seem as exciting as they did in the past but maybe that’s the time to do a little buying.
B. Prior to Webster’s complete two-volume edition he had compiled three shorter and incomplete versions.
C. Markets that will do well in the future include telecommunications and the energy sector.
D. Financial aspects of homebuying, factor into the equation for the need for additional capital outlays.

Identify the correct sentence.


Identify the correct sentence.


A. My American Literature class starts at 12:30 p.m.
B. My Literature class starts at 12:30 p.m.
C. My American literature class starts at 12:30 PM.
D. My literature class starts at 12:30 p.m. in the afternoon.

Never divide:


Never divide:


A. the last word on a page.
B. a word less than two syllables.
C. a contraction.
D. All of the above

Identify the correct sentence.


Identify the correct sentence.

A. I’ve seen the movie Raiders of the Lost Ark 3 times.
B. I’ve seen the movie Raiders Of The Lost Ark 3 times.
C. I’ve seen the movie Raiders of the Lost Ark three times.
D.I’ve seen the Movie Raiders of the Lost Ark three times.

If String x = "Hello" and String y = "Goodbye", then swap(x, y); results in which of the following?


Consider the following swap method. If String x = "Hello" and String y = "Goodbye", then swap(x, y); results in which of the following?


public void swap(String a, String b)

{

String temp;

temp = a;

a = b;

b = temp;

}

a) x is now "Goodbye" and y is now "Hello"

b) x is now "Goodbye" and y is still "Goodbye", but (x != y)

c) x is still "Hello" and y is now "Hello", but (x != y)

d) x and y are now aliases

e) x and y remain unchanged

Answer: e. Explanation: When x and y are passed to swap, a and x become aliases and b and y become aliases. The statement temp = a sets temp to be an alias of a and x. The statement a = b sets a to be an alias of b and y, but does not alter x or temp. Finally, b = temp sets b to be an alias of temp and y, but does not alter y. Therefore, x and y remain the same.

For questions 5-8, consider a class that stores 2 int values. These values can be assigned int values with the messages set1(x) and set2(x) where x is an int, and these values can be accessed through get1( ) and get2( ). Assume that y and z are two objects of this class. The following instructions are executed:


For questions 5-8, consider a class that stores 2 int values. These values can be assigned int values with the messages set1(x) and set2(x) where x is an int, and these values can be accessed through get1( ) and get2( ). Assume that y and z are two objects of this class. The following instructions are executed:

y.set1(5);

y.set2(6);

z.set1(3);

z.set2(y.get1( ));

y = z;

5) The statement z.get2( ); will


a) return 5

b) return 6

c) return 3

d) return 0

e) cause a run-time error

Answer: a. Explanation: The statement y.get1( ) returns the value 5, and therefore the statement z.set2(y.get1( )) sets the second value of z to be 5, so that z.get2( ) returns 5.

6) The statement y.get2( ); will


a) return 5

b) return 6

c) return 3

d) return 0

e) cause a run-time error

Answer: a. Explanation: The statement y = z; causes y and z to be aliases where y.get2( ); returns the same value as z.get2( );. Since z.set2(y.get1( )); was performed previously, z and y's second value is 5.

7) If the instruction z.set2(y.get1( )); is executed, which of the following is true?


a) (y = = z) is still true

b) (y.get1( ) = = z.get1( )) but (y.get2( ) != z.get2( ))

c) (y.get1( ) = = z.get1( )) and (y.get2( ) = = z.get2( )) but (y != z)

d) (y.get1( ) = = z.get2( )) and (y.get2( ) = = z.get1( )) but (y != z)

e) the statement causes a run-time error

Answer: a. Explanation: Since y=z; was performed previously, y and z are aliases, so that a change to one results in a change to the other. The statement z.set2(y.get1( )); is essentially the same as z.set2(z.get1( )); or y.set2(y.get1( )); and in any case, it sets the second value to equal the first for the object which is referenced by both y and z.

8) If the instructions z.set2(5); and y.set1(10); are performed, which of the following is true?


a) (y = = z) is still true

b) (y.get1( ) = = z.get1( )) but (y.get2( ) != z.get2( ))

c) (y.get1( ) = = z.get1( )) and (y.get2( ) = = z.get2( )) but (y != z)

d) (y.get1( ) = = z.get2( )) and (y.get2( ) = = z.get1( )) but (y != z)

e) this statement causes a run-time error

Answer: a. Explanation: Since y=z; was peformed previously, y and z are aliases meaning that they refer to the same object. The statement z.set2(5); causes a change to the object's second value while y.set1(10); causes a change to the object's first value but neither change the fact that y and z are aliases.

Assume x and y are String variables with x = "Hello" and y = null.


For questions 1-4, assume x and y are String variables with x = "Hello" and y = null.


1) The result of (x = = y) is


a) true

b) false

c) a syntax error

d) a run-time error

e) x being set to the value null

Answer: b. Explanation: x is a String instantiated to the value "Hello" and y is a String that has not yet been instantiated, so they are not the same String. (x = = y) is a condition, testing to see if x and y are the same String (that is, x and y reference the same item in memory), which they don't, so the result is false.

2) The result of x.length( ) + y.length( ) is


a) 0

b) 5

c) 6

d) 10

e) a thrown exception

Answer: e. Explanation: The statement y.length( ) results in a thrown NullPointException because it is not possible to pass a message to an object that is not currently instantiated (equal to null).

3) If the operation y = "Hello"; is performed, then the result of (x = = y) is


a) true

b) false

c) x and y becoming aliases

d) x being set to the value null

e) a run-time error

Answer: b. Explanation: While x and y now store the same value, they are not the same String, that is, x and y reference different objects in memory, so the result of the condition (x = = y) is false.

4) If the operation y = x; is performed, then the result of (x = = y) is


a) true

b) false

c) x being set to the value null while y retains the value "Hello"

d) y being set to the value null while x retains the value "Hello"

e) x being set to y, which it is already since y = x; was already performed

Answer: a. Explanation: When y = x; was performed, the two variables are now aliases, that is, they reference the same thing in memory. So, (x = = y) is now true.

Consider a method defined with the header: public void doublefoo(double x). Which of the following method calls is legal?


Consider a method defined with the header: public void doublefoo(double x). Which of the following method calls is legal?


a) doublefoo(0);

b) doublefoo(0.555);

c) doublefoo(0.1 + 0.2);

d) doublefoo(0.1, 0.2);

e) all of the above are legal except for d

Answer: e. Explanation: In the case of a, the value 0 (an int) is widened to a double. In the case of c, the addition is performed yielding 0.3 and then doublefoo is called. The parameter list in d is illegal since it contains two double parameters instead of 1.

Consider a method defined with the header: public void foo(int a, int b). Which of the following method calls is legal?


Consider a method defined with the header: public void foo(int a, int b). Which of the following method calls is legal?


a) foo(0, 0.1);

b) foo(0 / 1, 2 * 3);

c) foo(0);

d) foo( );

e) foo(1 + 2, 3 * 0.1);

Answer: b. Explanation: The only legal method call is one that passes two int parameters. In the case of answer b, 0 / 1 is an int division (equal to 0) and 2 * 3 is an int multiplication. So this is legal. The answers for a and e contain two parameters, but the second of each is a double. The answers for c and d have the wrong number of parameters.

For questions 21 - 23, use the following class definition:


For questions 21 - 23, use the following class definition:


public class Swapper

{

private int x;

private String y;

public int z;

public Swapper(int a, String b, int c)

{

x = a;

y = b;

z = c;

}

public String swap( )

{

int temp = x;

x = z;

z = temp;

return y;

}

public String toString( )

{

if (x < z) return y;

else return "" + x + z;

}

}

21) If the instruction Swapper s = new Swapper(0, "hello", 0); is executed followed by s.toString( ); what value is


returned from s.toString( )?

a) "hello"

b) "hello00"

c) "00"

d) "0"

e) 0

Answer: c. Explanation: The toString method compares x and z, and if x < y it returns the String y. In this case, x ==z, so the else clause is executed, and the String of "" + x + z is returned. This is the String "00".

22) Which of the following criticisms is valid about the Swapper class?


a) The instance data x is visible outside of Swapper

b) The instance data y is visible outside of Swapper

c) The instance data z is visible outside of Swapper

d) All 3 instance data are visible outside of Swapper

e) None of the methods are visible outside of Swapper


Answer: c. Explanation: We would expect none of the instance data to be visible outside of the class, so they should all be declared as “private” whereas we would expect the methods that make up the interface to be visible outside of the class, so they should all be declared as “public”. We see that z is declared “public” instead of “private”.

23) If we have Swapper r = new Swapper (5, "no", 10); then r.swap( ); returns which of the following?


a) nothing

b) "no"

c) "no510"

d) "510"

e) "15"

Answer: b. Explanation: The swap method swaps the values of x and z (thus x becomes 10 and z becomes 5) and returns the value of y, which is “no” for r.

Use the following information to answer questions 19 - 20. The Die class from chapter 4 has two constructors defined as follows. Assume MIN_FACES is an int equal to 4. public Die( ) public Die(int faces) { { numFaces = 6; if(faces < MIN_FACES) numFaces = 6; faceValue = 1; else numFaces = faces; } faceValue = 1; }


Use the following information to answer questions 19 - 20. The Die class from chapter 4 has two constructors defined as follows. Assume MIN_FACES is an int equal to 4.


public Die( ) public Die(int faces)

{ {

numFaces = 6; if(faces < MIN_FACES) numFaces = 6;

faceValue = 1; else numFaces = faces;

} faceValue = 1;

}

1) The instruction Die d = new Die(10); results in


a) The Die d having numFaces = 6 and faceValue = 1

b) The Die d having numFaces = 10 and faceValue = 1

c) The Die d having numFaces = 10 and faceValue = 10

d) The Die d having numFaces = 6 and faceValue = 10

e) A syntax error

Answer: b. Explanation: Since an int parameter is passed to the constructor, the second constructor is executed, which sets numFaces = 10 (since numFaces >= MIN_FACES) and faceValue = 1.

2) The instruction Die d = new Die(10, 0); results in


a) The Die d having numFaces = 6 and faceValue = 1

b) The Die d having numFaces = 10 and faceValue = 1

c) The Die d having numFaces = 10 and faceValue = 10

d) The Die d having numFaces = 6 and faceValue = 10

e) A syntax error

Answer: e. Explanation: The Die class has two constructors, one that receives no parameters and one that receives a single int parameter. The instruction above calls the Die constructor with 2 int parameters. Since no constructor matches this number of parameters exists, a syntax error occurs.

In the Rational class, defined in chapter 4, the methods reduce and gcd are declared to be private. Why?


In the Rational class, defined in chapter 4, the methods reduce and gcd are declared to be private. Why?


a) Because they will never be used

b) Because they will only be called from methods inside of Rational

c) Because they will only be called from the constructor of Rational

d) Because they do not use any of Rational’s instance data

e) Because it is a typo and they should be declared as public

Answer: b. Explanation: All items of a class that are declared to be private are only accessible to entities within that class, whether they are instance data or methods. In this case, since these two methods are only called from other methods (including the constructor) of Rational, they are declared private to promote information hiding to a greater degree. Note that answer c is not a correct answer because the reduce method calls the gcd method, so one of the methods is called from a method other than the constructor.

int num = 0; for(int j = 0; j < 1000; j++) { c.flip( ); if(c.isHeads()) num++; } double value = (double) num / 1000;


What does the following code compute?


int num = 0;

for(int j = 0; j < 1000; j++)

{

c.flip( );

if(c.isHeads()) num++;

}

double value = (double) num / 1000;

1) the number of Heads flipped out of 1000 flips

2) the number of Heads flipped in a row out of 1000 flips

3) the percentage of heads flipped out of 1000 flips

4) the percentage of times neither Heads nor Tails were flipped out of 1000 flips

5) nothing at all

Answer: c. Explanation: The code iterates 1000 times, flipping the Coin and testing to see if this flip was a 0 (“Heads”) or 1 (“Tails”). The variable num counts the number of Heads and the variable value is then the percentage of Heads over 1000.

A set of code has already instantiated c to be a Coin and has input a String guess, from the user asking whether the user guesses that a coin flip will result in “Heads” or “Tails”. Which of the following sets of code will perform the coin flip and see if the user’s guess was right or wrong?


A set of code has already instantiated c to be a Coin and has input a String guess, from the user asking whether the user guesses that a coin flip will result in “Heads” or “Tails”. Which of the following sets of code will perform the coin flip and see if the user’s guess was right or wrong?


a) c.flip( );

if(c.isHeads( ).equals(guess)) System.out.println("User is correct");

b) if(c.flip( ).equals(guess)) System.out.println("User is correct");

c) if(c.isHeads( ).equals(guess)) System.out.println("User is correct");

Lewis/Loftus/Cocking: Chapter 4 Test Bank TB 39

d) c.flip( );

if(c.toString( ).equals(guess)) System.out.println("User is correct");

e) c.flip( ).toString( );

if(c.equals(guess)) System.out.println("User is correct");

Answer: d. Explanation: c.flip( ) must be performed first to get a Coin flip. Next, the user’s guess is compared against the value of the Coin’s flip. The Coin c stores the result as an int and the user’s guess is a String. Using getFace( ) returns the int value but using the toString method will return the String “Heads” or “Tails”. So, the code compares c.toString( ) with the user’s guess using the String method equals.

Another method that might be desired is one that updates the Student’s number of credit hours. This method will receive a number of credit hours and add these to the Student’s current hours. Which of the following methods would accomplish this?


Another method that might be desired is one that updates the Student’s number of credit hours. This method will receive a number of credit hours and add these to the Student’s current hours. Which of the following methods would accomplish this?


a) public int updateHours( )

{

return hours;

}

b) public void updateHours( )

{

hours++;

}

c) public updateHours(int moreHours)

{

hours += moreHours;

}

d) public void updateHours(int moreHours)

{

hours += moreHours;

}

e) public int updateHours(int moreHours)

{

return hours + moreHours;

}

Answer: d. Explanation: This method will receive the number of new hours and add this to the current hours. The method in d is the only one to do this appropriately. Answer c is syntactically invalid since it does not list a return type. The answer in e returns the new hours, but does not reset hours appropriately. The Coin class, as defined in Chapter 4, consists of a constructor, and methods flip, isHeads and toString. The method isHeads returns true if the last flip was a Heads, and false if the last flip was a Tails. The toString method returns a String equal to “Heads” or “Tails” depending on the result of the last flip. Using this information, answer questions 16– 17

For questions 13-15, use the following class definition


For questions 13-15, use the following class definition

import java.text.DecimalFormat;

public class Student

{

private String name;

private String major;

private double gpa;

private int hours;

public Student(String newName, String newMajor, double newGPA, int newHours)

{

name = newName;

major = newMajor;

gpa = newGPA;

hours = newHours;

}

public String toString( )

{

DecimalFormat df = new DecimalFormat("xxxx"); // xxxx needs to be replaced

return name + "\n" + major + "\n" + df.format(gpa) + "\n" + hours

}

}

1) Which of the following could be used to instantiate a new Student s1?


a) Student s1 = new Student( );

b) s1 = new Student( );

c) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);

d) new Student s1 = ("Jane Doe", "Computer Science", 3.333, 33);

e) new Student(s1);

Answer: c. Explanation: To instantiate a class, the object is assigned the value returned by calling the constructor preceded by the reserved word new, as in new Student( ). The constructor might require parameters, and for Student, the parameters must be are two String values, a double, followed by an int.

2) Assume that another method has been defined that will compute and return the student’s class rank (Freshman, Sophomore, etc). It is defined as:public String getClassRank( )

 Given that s1 is a student, which of the following would properly be used to get s1’s class rank?


a) s1 = getClassRank( );

b) s1.toString( );

c) s1.getHours( );

d) s1.getClassRank( );

e) getClassRank(s1);

Answer: d. Explanation: To call a method of an object requires passing that object a message which is the same as the method name, as in object.methodname(parameters). In this situation, the object is s1, the method is getClassRank, and this method expects no parameters. Answers a and e are syntactically illegal while answer b returns information about the Student but not his/her class rank, and there is no “getHours” method so c is also syntactically illegal.

An example of passing a message to a String where the message has a String parameter occurs in which of the following messages?


An example of passing a message to a String where the message has a String parameter occurs in which of the following messages?


a) length

b) substring

c) equals

d) toUpperCase

e) none of the above, it is not possible to pass a String as a parameter in a message to a String

Answer: c. Explanation: The length and toUpperCase messages do not have parameters and substring has two int parameters. For equals, a String must be passed as a parameter so that the String receiving the message can be compared to the String passed as a parameter.

Instance data for a Java class


Instance data for a Java class


a) are limited to primitive types (e.g., int, double, char)

b) are limited to Strings

Lewis/Loftus/Cocking: Chapter 4 Test Bank TB 37

c) are limited to objects(e.g., Strings, classes defined by other programmers)

d) may be primitive types or objects, but objects must be defined to be private

e) may be primitive types or objects

Answer: e. Explanation: The instance data are the entities that make up the class and may be any type available whether primitive or object, and may be public or private. By using objects as instance data, it permits the class to be built upon other classes. This relationship where a class has instance data that are other classes is known as a has-a relationship.

Having multiple class methods of the same name where each method has a different number of or type of parameters is known as


Having multiple class methods of the same name where each method has a different number of or type of parameters is known as


a) encapsulation

b) information hiding

c) tokenizing

d) importing

e) method overloading

Answer: e. Explanation: When methods share the same name, they are said to be overloaded. The number and type of parameters passed in the message provides the information by which the proper method is called.

A class’ constructor usually defines


A class’ constructor usually defines


a) how an object is initialized

b) how an object is interfaced

c) the number of instance data in the class

d) the number of methods in the class

e) if the instance data are accessible outside of the object directly

Answer: a. Explanation: The constructor should be used to “construct” the object, that is, to set up the initial values of the instance data. This is not essential, but is typically done. The interface of an object is dictated by the visibility modifiers used on the instance data and methods.

A variable whose scope is restricted to the method where it was declared is known as a(n)


A variable whose scope is restricted to the method where it was declared is known as a(n)


a) parameter

b) global variable

c) local variable

d) public instance data

e) private instance data

Answer: c. Explanation: Local variables are those that are “local” to the method in which they have been declared, that is, they are accessible only inside that method. Global variables are those that are accessible from anywhere, while parameters are the variables passed into a method. Instance data can be thought of as global variables for an entire

object.

Consider a sequence of method invocations as follows: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m4 has just terminated, what method will resume execution?


Consider a sequence of method invocations as follows: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m4 has just terminated, what method will resume execution?


a) m1

b) m2

c) m3

d) m5

e) main

Answer: b. Explanation: Once a method terminates, control resumes with the method that called that method. In this case, m2 calls m4, so that when m4 terminates, m2 is resumed.

If a method does not have a return statement, then


If a method does not have a return statement, then


a) it will produce a syntax error when compiled

b) it must be a void method

c) it can not be called from outside the class that defined the method

d) it must be defined to be a public method

e) it must be an int, double, or String method

Answer: b. Explanation: All methods are implied to return something and therefore there must be a return statement. However, if the programmer wishes to write a method that does not return anything, and therefore does not need a return statement, then it must be a void method (a method whose header has “void” as its return type).

In order to preserve encapsulation of an object, we would do all of the following except for which one?


In order to preserve encapsulation of an object, we would do all of the following except for which one?


a) Make the instance data private

b) Define the methods in the class to access and manipulate the instance data

c) Make the methods of the class public

d) Make the class final

e) All of the above preserve encapsulation

Answer: d. Explanation: Encapsulation means that the class contains both the data and the methods needed to manipulate the data. In order to preserve encapsulation properly, the instance data should not be directly accessible from outside of the classes, so the instance data are made private and methods are defined to access and manipulate the instance data. Further, the methods to access and manipulate the instance data are made public so that other classes can use the object. The reserved word “final” is usedto control inheritance and has nothing to do with encapsulation.

Which of the following reserved words in Java is used to create an instance of a class?


Which of the following reserved words in Java is used to create an instance of a class?


a) class

b) public

c) public or private, either could be used

d) import

e) new

Answer: e. Explanation: The reserved word “new” is used to instantiate an object, that is, to create an instance of a class. The statement new is followed by the name of the class. This calls the class’ constructor. Example: Car x = newCar( ); will create a new instance of a Car and set the variable x to it.

To define a class that will represent a car, which of the following definitions is most appropriate?


To define a class that will represent a car, which of the following definitions is most appropriate?


a) private class car

b) public class car

c) public class Car

d) public class CAR

e) private class Car

Answer: c. Explanation: Classes should be defined to be public so that they can be accessed by other classes. And following Java naming convention, class names should start with a capital letter and be lower case except for the beginning of each new word, so Car is more appropriate than car or CAR.

The relationship between a class and an object is best described as


The relationship between a class and an object is best described as


a) classes are instances of objects

b) objects are instances of classes

c) objects and classes are the same thing

d) classes are programs while objects are variables

e) objects are the instance data of classes

Answer: b. Classes are definitions of program entities that represent classes of things/entities in the world. Class definitions include instance data and methods. To use a class, it is instantiated. These instances are known as objects. So, objects are instances of classes. Program code directly interacts with objects, not classes.

The behavior of an object is defined by the object’s a) instance data b) constructor c) visibility modifiers d) methods e) all of the above


The behavior of an object is defined by the object’s


a) instance data

b) constructor

c) visibility modifiers

d) methods

e) all of the above

Answer: d. Explanation: The methods dictate how the object reacts when it is passed messages. Each message is implemented as a method, and the method is the code that executes when the message is passed. The constructor is one of these methods but all of the methods combine dictate the behavior. The visibility modifiers do impact the object’s performance indirectly.

public void paint(Graphics page) { int x, y = 200; page.setColor(Color.blue); for(x = 100; x < 200; x += 20) page.fillRect(x, y, 10, y-x); }


Consider the following paint method and answer questions :


public void paint(Graphics page)

{

int x, y = 200;

page.setColor(Color.blue);

for(x = 100; x < 200; x += 20)

page.fillRect(x, y, 10, y-x);



1) This paint method will draw several bars (sort of like a bar graph). How many bars will be displayed?


a) 4

b) 5

c) 6

d) 10

e) 20

Answer: b. Explanation: Since x iterates from 100 up to 200 in units of 20, it iterates 5 times (x = 100, x = 120, x= 140, x = 160, x = 180).

2) The size of each rectangle (bar)


a) increases in height while staying the same width

b) increases in width while staying the same height

c) increases in both width and height

d) stays the same size

e) decreases in height while staying the same width

Answer: e. Explanation: The width is a constant 10. The height is y-x where x increases by 20 each iteration, so the height decreases by 20.