0% found this document useful (0 votes)
32 views

Answers to Problems from Java: How to Program – Early Objects, 11th Edition by Paul & Harvey Deitel

The document serves as an introduction to computers, the internet, and Java programming, outlining key objectives such as understanding hardware, software, networking basics, and the significance of Java. It includes self-review exercises and practical applications related to programming concepts, object-oriented programming, and environmental awareness. Additionally, it encourages readers to engage with real-world issues through exercises focused on carbon footprints, body mass index, and gender neutrality in communication.

Uploaded by

organicc488
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Answers to Problems from Java: How to Program – Early Objects, 11th Edition by Paul & Harvey Deitel

The document serves as an introduction to computers, the internet, and Java programming, outlining key objectives such as understanding hardware, software, networking basics, and the significance of Java. It includes self-review exercises and practical applications related to programming concepts, object-oriented programming, and environmental awareness. Additionally, it encourages readers to engage with real-world issues through exercises focused on carbon footprints, body mass index, and gender neutrality in communication.

Uploaded by

organicc488
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

You can access complete document on following URL.

Contact me if site not loaded


https://unihelp.xyz/

Introduction to Computers,
the Internet and Java 1
sm

Objectives
In this chapter you’ll:
tb9
■ Learn about exciting recent
developments in the computer
field.
■ Learn computer hardware,
software and networking
basics.
8@
■ Understand the data hierarchy.

■ Understand the different types


of programming languages.
■ Understand the importance of
Java and other leading
programming languages.
■ Understand object-oriented
gm

programming basics.
■ Learn Internet and web basics.

■ Learn a typical Java program-


development environment.
■ Test-drive a Java application.

■ Learn some key recent


ail

software technologies.
.co
m

Contact me in order to access the whole complete document - Email: [email protected]


WhatsApp: https://wa.me/message/2H3BV2L5TTSUF1 - Telegram: https://t.me/solutionmanual
2 Chapter 1 Introduction to Computers, the Internet and Java

Self-Review Exercises
1.1 Fill in the blanks in each of the following statements:
a) Computers process data under the control of sets of instructions called .
ANS: programs.
b) The key logical units of the computer are the , , ,
, and .
ANS: input unit, output unit, memory unit, central processing unit, arithmetic and logic
unit, secondary storage unit.
c) The three types of languages discussed in the chapter are , and
.
ANS: machine languages, assembly languages, high-level languages.
d) The programs that translate high-level language programs into machine language are
called .
ANS: compilers.
e) is an operating system for mobile devices based on the Linux kernel and Java.
ANS: Android.
f) software is generally feature complete, (supposedly) bug free and ready for
use by the community.
ANS: Release candidate.
g) The Wii Remote, as well as many smartphones, use a(n) which allows the de-
vice to respond to motion.
ANS: accelerometer.
1.2 Fill in the blanks in each of the following sentences about the Java environment:
a) The command from the JDK executes a Java application.
ANS: java.
b) The command from the JDK compiles a Java program.
ANS: javac.
c) A Java source code file must end with the file extension.
ANS: .java.
d) When a Java program is compiled, the file produced by the compiler ends with the
file extension.
ANS: .class.
e) The file produced by the Java compiler contains that are executed by the Java
Virtual Machine.
ANS: bytecodes.
1.3 Fill in the blanks in each of the following statements (based on Section 1.5):
a) Objects enable the design practice of —although they may know how to com-
municate with one another across well-defined interfaces, they normally are not allowed
to know how other objects are implemented.
ANS: information hiding.
b) Java programmers concentrate on creating , which contain fields and the set
of methods that manipulate those fields and provide services to clients.
ANS: classes.
c) The process of analyzing and designing a system from an object-oriented point of view
is called .
ANS: object-oriented analysis and design (OOAD).
Exercises 3

d) A new class of objects can be created conveniently by —the new class (called
the subclass) starts with the characteristics of an existing class (called the superclass),
possibly customizing them and adding unique characteristics of its own.
ANS: Inheritance.
e) is a graphical language that allows people who design software systems to use
an industry-standard notation to represent them.
ANS: The Unified Modeling Language (UML).
f) The size, shape, color and weight of an object are considered of the object’s
class.
ANS: attributes.

Exercises
1.4 Fill in the blanks in each of the following statements:
a) The logical unit that receives information from outside the computer for use by the
computer is the .
ANS: input unit.
b) The process of instructing the computer to solve a problem is called .
ANS: computer programming.
c) is a type of computer language that uses Englishlike abbreviations for ma-
chine-language instructions.
ANS: Assembly language.
d) is a logical unit that sends information which has already been processed by
the computer to various devices so that it may be used outside the computer.
ANS: The output unit.
e) and are logical units of the computer that retain information.
ANS: The memory unit, the secondary storage unit.
f) is a logical unit of the computer that performs calculations.
ANS: The arithmetic and logic unit (ALU).
g) is a logical unit of the computer that makes logical decisions.
ANS: The arithmetic and logic unit (ALU).
h) languages are most convenient to the programmer for writing programs
quickly and easily.
ANS: High-level.
i) The only language a computer can directly understand is that computer’s .
ANS: machine language.
j) is a logical unit of the computer that coordinates the activities of all the other
logical units.
ANS: The central processing unit (CPU).
1.5 Fill in the blanks in each of the following statements:
a) The programming language is now used to develop large-scale enterprise ap-
plications, to enhance the functionality of web servers, to provide applications for con-
sumer devices and for many other purposes.
ANS: Java.
b) initially became widely known as the development language of the UNIX op-
erating system.
ANS: C.
4 Chapter 1 Introduction to Computers, the Internet and Java

c) The ensures that messages, consisting of sequentially numbered pieces called


bytes, were properly routed from sender to receiver, arrived intact and were assembled
in the correct order.
ANS: Transmission Control Protocol (TCP).
d) The programming language was developed by Bjarne Stroustrup in the early
1980s at Bell Laboratories.
ANS: C++.
1.6 Fill in the blanks in each of the following statements:
a) Java programs normally go through five phases— , , ,
and .
ANS: edit, compile, load, verify, execute.
b) A(n) provides many tools that support the software development process,
such as editors for writing and editing programs, debuggers for locating logic errors in
programs, and many other features.
ANS: integrated development environment (IDE).
c) The command java invokes the , which executes Java programs.
ANS: Java Virtual Machine (JVM).
d) A(n) is a software application that simulates a computer, but hides the under-
lying operating system and hardware from the programs that interact with it.
ANS: virtual machine (VM).
e) The takes the .class files containing the program’s bytecodes and transfers
them to primary memory.
ANS: class loader.
f) The examines bytecodes to ensure that they’re valid.
ANS: bytecode verifier.
1.7 Explain the two compilation phases of Java programs.
ANS: The two compilation phases that Java programs typically go through include one in
which source code is translated into bytecodes which are portable across JVMs and a
second in which the bytecodes are translated into machine language for the actual
computer on which the program executes. In early Java versions, the JVM was simply
an interpreter for Java bytecodes. This caused most Java programs to execute slowly
because the JVM would interpret and execute one bytecode at a time. Today’s JVMs
typically execute bytecodes using a combination of interpretation and so-called just-
in-time (JIT) compilation. In this process, The JVM analyzes the bytecodes as they
are interpreted, searching for hot spots—parts of the bytecodes that execute frequent-
ly. For these parts, a just-in-time (JIT) compiler—known as the Java HotSpot com-
piler—translates the bytecodes into the underlying computer’s machine language.
When the JVM encounters these compiled parts again, the faster machine-language
code executes.
1.8 One of the world’s most common objects is a wrist watch. Discuss how each of the follow-
ing terms and concepts applies to the notion of a watch: object, attributes, behaviors, class, inheri-
tance (consider, for example, an alarm clock), modeling, messages, encapsulation, interface and
information hiding.
ANS: The entire watch is an object that is composed of many other objects (such as the
moving parts, the band, the face, etc.) Watch attributes are time, color, band, style
(digital or analog), etc. The behaviors of the watch include setting the time and get-
ting the time. A watch can be considered a specific type of clock (as can an alarm
clock). With that in mind, it is possible that a class called Clock could exist from
which other classes such as watch and alarm clock could inherit the basic features in
Making a Difference 5

the clock. The watch is an abstraction of the mechanics needed to keep track of the
time. The user of the watch does not need to know the mechanics of the watch in
order to use it; the user only needs to know that the watch keeps the proper time. In
this sense, the mechanics of the watch are encapsulated (hidden) inside the watch.
The interface to the watch (its face and controls for setting the time) allows the user
to set and get the time. The user is not allowed to directly touch the internal mechan-
ics of the watch. All interaction with the internal mechanics is controlled by the in-
terface to the watch. The data members stored in the watch are hidden inside the
watch and the member functions (looking at the face to get the time and setting the
time) provide the interface to the data.

Making a Difference
The Making-a-Difference exercises will ask you to work on problems that really matter to individ-
uals, communities, countries and the world.
1.9 (Test Drive: Carbon Footprint Calculator) Some scientists believe that carbon emissions,
especially from the burning of fossil fuels, contribute significantly to global warming and that this
can be combated if individuals take steps to limit their use of carbon-based fuels. Various organiza-
tions and individuals are increasingly concerned about their “carbon footprints.” Websites such as
TerraPass
http://www.terrapass.com/carbon-footprint-calculator-2/

and Carbon Footprint


http://www.carbonfootprint.com/calculator.aspx

provide carbon-footprint calculators. Test drive these calculators to determine your carbon foot-
print. Exercises in later chapters will ask you to program your own carbon-footprint calculator. To
prepare for this, research the formulas for calculating carbon footprints.
1.10 (Test Drive: Body-Mass-Index Calculator) By recent estimates, two-thirds of the people in
the United States are overweight and about half of those are obese. This causes significant increases
in illnesses such as diabetes and heart disease. To determine whether a person is overweight or obese,
you can use a measure called the body mass index (BMI). The United States Department of Health
and Human Services provides a BMI calculator at http://www.nhlbi.nih.gov/guidelines/
obesity/BMI/bmicalc.htm. Use it to calculate your own BMI. An exercise in Chapter 3 will ask you
to program your own BMI calculator. To prepare for this, research the formulas for calculating BMI.
1.11 (Attributes of Hybrid Vehicles) In this chapter you learned the basics of classes. Now you’ll
begin “fleshing out” aspects of a class called “Hybrid Vehicle.” Hybrid vehicles are becoming increas-
ingly popular, because they often get much better mileage than purely gasoline-powered vehicles.
Browse the web and study the features of four or five of today’s popular hybrid cars, then list as many
of their hybrid-related attributes as you can. For example, common attributes include city-miles-per-
gallon and highway-miles-per-gallon. Also list the attributes of the batteries (type, weight, etc.).
ANS:
• Manufacturer
• Type of Hybrid—Battery hybrid (Hybrid Electric Vehicles), Plug-in hybrid, Fuel cell etc.
• Driver feedback system—so the driver can monitor fuel efficiency based on their driving
• Energy recovery—for example, regenerative breaking
• Carbon footprint—tons of CO2 per year
• Fuel capacity
• City-miles-per-gallon
6 Chapter 1 Introduction to Computers, the Internet and Java

• Highway-miles-per-gallon
• Two-mode hybrid propulsion system
• Engine size—V6, V8, etc.
• Vehicle type—SUV, crossover, compact, mid-size, etc.
• Seating capacity
• Horse power
• Drive train (front wheel drive, all wheel drive)
• Top speed
• Torque
• Price
1.12 (Gender Neutrality) Some people want to eliminate sexism in all forms of communication.
You’ve been asked to create a program that can process a paragraph of text and replace gender-spe-
cific words with gender-neutral ones. Assuming that you’ve been given a list of gender-specific
words and their gender-neutral replacements (e.g., replace “wife” with “spouse,” “man” with “per-
son,” “daughter” with “child” and so on), explain the procedure you’d use to read through a para-
graph of text and manually perform these replacements. How might your procedure generate a
strange term like “woperchild?” In Chapter 4, you’ll learn that a more formal term for “procedure”
is “algorithm,” and that an algorithm specifies the steps to be performed and the order in which to
perform them.
ANS: Search through the entire paragraph for a word such as “wife” and replace every oc-
currence with “spouse.” Repeat this searching process for every gender specific word
in the list. You could accidentally get a word like “woperchild” if you are not careful
about how you perform replacements. For example, the word “man” can be part of
a larger word, like “woman.” So, replacing every occurrence of “man” can yield
strange results. Consider the process of replacing “man” with “person” then replacing
“son” with “child.” If you encounter the word “woman,” which contains the word
“man,” you’d replace “man” with “person” resulting in the word “woperson.” In a
subsequent pass you’d encounter “woperson” and replace “son” with “child” result-
ing in the “woperchild.”
1.13 (Intelligent Assistants) Developments in the field of artificial intelligence have been acceler-
ating in recent years. Many companies now offer computerized intelligent assistants, such as IBM’s
Watson, Amazon’s Alexa, Apple’s Siri, Google’s Google Now and Microsoft’s Cortana. Research
these and others and list uses that can improve people’s lives.
1.14 (Big Data) Research the rapidly growing field of big data. List applications that hold great
promise in fields such as healthcare and scientific research.
1.15 (Internet of Things) It’s now possible to have a microprocessor at the heart of just about any
device and to connect those devices to the Internet. This has led to the notion of the Internet of
Things (IoT), which already interconnects tens of billions of devices. Research the IoT and indicate
the many ways it’s improving people’s lives.

You might also like