JHTP练习题及课题_第一章_计算机、互联网及Java简介

来源:互联网 发布:ubuntu权限不够怎么办 编辑:程序博客网 时间:2024/06/07 00:36

Exercises


1.4Fill in the blanks in each of the following statements:


a) The logical unit that receives information from outside thecomputer for use by thecomputer is theinput unit.


b) The process of instructing the computer to solve a problem iscalledprogramming.


c)High-level language is a type of computer languagethat uses Englishlike abbreviations for machine-language instructions.


d)Output unit is a logical unit that sends informationwhich has already been processed by the computer to various devices so that itmay be used outside the computer.


e)Memory unit and are logical units of the computer thatretain information.


f)ALU is a logical unit of the computer that performscalculations.


g)CPU is a logical unit of the computer that makeslogical decisions.


h)Machine languages are most convenient to theprogrammer for writing programs quickly and easily.


i) The only language a computer can directly understand is thatcomputer’smachine language.


j)CPU is a logical unit of the computer thatcoordinates the activities of all the other logical units.


1.5Fill in the blanks in each of the following statements:


a) TheJavaprogramming language is now used to developlarge-scale enterprise applications, to enhance the functionality of webservers, to provide applications for consumer devices and for many otherpurposes.


b)C language initially became widely known as thedevelopment language of the UNIX operating system.


c) Therouter ensures that messages, consisting ofsequentially numbered pieces calledbytes, were properly routed from sender to receiver, arrivedintact and were assembledin the correct order.


d) TheC++ programming language was developed by BjarneStroustrup in the early 1980s at Bell Laboratories.


1.6Fill in the blanks in each of the following statements:


a) Java programs normally go through five phases—edit, compile, load, verifyand execution.


b) A(n)IDE provides many tools that support the softwaredevelopment process,such as editors for writing and editing programs, debuggers forlocating logic errors inprograms, and many other features.


c) The commandjavainvokes theJVM,which executes Java programs.


d) A(n)virtual machine is a software application thatsimulates a computer, but hides the underlying operating system and hardwarefrom the programs that interact with it.


e) TheJVM class loader takes the.classfiles containing the program’s bytecodes and transfers them toprimary memory.


f) Thebytecode verifier examines bytecodes to ensurethat they’re valid.


1.7Explain the two compilation phases of Java programs.


1.8One of the world’s most common objects is a wrist watch. Discusshow each of the following terms and concepts applies to the notion of a watch:object, attributes, behaviors, class, inheritance(consider, for example, analarm clock), modeling, messages, encapsulation, interface and informationhiding.


Making a Difference


Throughout the book we’ve included Making a Difference exercisesin which you’ll be asked to work on problems that really matter to individuals,communities, countries and the world. For more information about worldwideorganizations working to make a difference, and for related programming projectideas, visit our Making a Difference Resource Center atwww.deitel.com/makingadifference.


1.9(Test-Drive: Carbon Footprint Calculator)Some scientists believe that carbon emissions,especially from the burning of fossil fuels, contribute significantly to globalwarming and that this can be combatted if individuals take steps to limit theiruse of carbon-based fuels. Organizations and individuals are increasinglyconcerned about their “carbon footprints.” Websites such as TerraPasshttp://www.terrapass.com/carbon-footprint-calculator/and Carbon Footprinthttp://www.carbonfootprint.com/calculator.aspx provide carbon-footprint calculators.Test-drive these calculators to determine your carbon footprint.

Exercises in later chapters will ask you to program your own carbon-footprintcalculator. To prepare for this, use the web to research the formulas forcalculating carbon footprints.


1.10(Test-Drive: Body Mass IndexCalculator)Obesitycauses significant increases in illnesses such as diabetes and heart disease.To determine whether a person is overweight or obese, you can use a measurecalled the body mass index (BMI). The United States Department of Health andHuman Services provides a BMI calculator athttp://www.nhlbi.nih.gov/guidelines/obesity/BMI/bmicalc.htm. Use it to calculate your own BMI. A forthcomingexercise will ask you to program your own BMI calculator. To prepare for this,use the web to research the formulas for calculating BMI.


1.11(Attributes of Hybrid Vehicles)In this chapter you learned some basics ofclasses. Now you’ll“flesh out” aspects of a class called “Hybrid Vehicle.”Hybrid vehicles are becoming increasingly popular, because they often get muchbetter mileage than purely gasoline-powered vehicles. Browse the web and studythe features of four or five of today’s popular hybrid cars, then list as manyof their hybrid-related attributes as you can. Some common attributes includecity-miles-per-gallon and highway-miles-per-gallon. Also list the attributes ofthe batteries (type, weight, etc.).


1.12(Gender Neutrality)Many people want to eliminate sexism in allforms of communication. You’ve been asked to create a program that can processa paragraph of text and replace gender-specific words with gender-neutral ones.Assuming that you’ve been given a list of gender-specific words and theirgender-neutral replacements (e.g., replace both “wife” and “husband” with“spouse,”“man” and “woman” with “person,” “daughter” and “son” with “child”), explainthe procedure you’d use to read through a paragraph of text and manuallyperform these replacements.

How might your procedure generate a strange term like “woperchild?”You’ll soon learn that a more formal term for “procedure” is “algorithm,” andthat an algorithm specifies the steps to be performed and the order in which toperform them. We’ll show how to develop algorithms then convert them to Javaprograms which can be run on computers.



1 0
原创粉丝点击