Proposed Solutions to the questions in the book Java How To Program 9TH edition by Paul Deitel & Harvey Deitel.(Excluding the self-review exercices)
Chapter 1
Exercice 1.4 Fill in the blanks in each of the following statements:
- The logical unit of the computer that receives information from outside the computer for use by the computer is the______ .
- The process of instructing the computer to solve a problem is called____?
- _____is a type of computer language that uses English-like abbreviations for machine-language instructions.
- ______is a logical unit of the computer that sends information which has already been processed by the computer to various devices so that it may be used outside the computer.
- ______and _____ are logical units of the computer that retain information.
- _____is a logical unit of the computer that performs calculations.
- _______is a logical unit of the computer that makes logical decisions.
- ______languages are most convenient to the programmer for writing programs quickly and easily.
- The only language a computer can directly understand is that computer’s______
- _____is a logical unit of the computer that coordinates the activities of all the other logical units.
- The input unit(in the text book page8, it is written that the input unit obtains information from input devices and places it at the disposal of other units for processing)
- Programming
- Assembly language(pg.9 instead of using the strings of numbers that computers could directly understand,programmers began using English-like abbreviations to represent elementary operations)
- Output unit (in the text book page9, it is written that processed information is taken by the computer and sent to the output devices so as to make it available for use outside the computer )
- i)The memory unit (page 9 it is described as a rapid-access relatively low capacity "warehouse " which retains input information and makes it available for processing when necessary )
- (ii)The secondary storage unit (page 9 it is stated that programs or data not actively used by the other units are stored in secondary storage devices)
- The Arithmetic and Logic Unit (ALU) (pg9 is described as the section which performs calculations such as addition, subtraction, multiplication and division )
- The ALU (pg 9 it is also stated that as of today's systems, the ALU is usually implemented as part of the next logical unit, i.e. the CPU )
- High-level languages (pg.10 such programs were developed to speed the programming process)
- Machine language(page 10 they state that any computer can directly understand only its own machine language which is defined by its hardware design)
- The central processing unit (CPU)the Central Processing Unit(CPU) (PAGE 9 this unit is described as coordinating and supervising the operation of other sections) nb// it is also stated that as of today's systems, the ALU is usually implemented as part of the next logical unit, i.e. the CPU
Exercise 1.5 Fill in the blanks in each of the following statements:
- ____is now used to develop large-scale enterprise applications, to enhance the functionality of web servers, to provide applications for consumer devices and for many other purposes.
- _____initially became widely known as the development language of the Unix operating system.
- The Web 2.0 company _____ is the fastest growing company ever.
- The ______ programming language was developed by Bjarne Stroustrup in the early 1980s at Bell Laboratories.
- Java Enterprise Edition (Java EE)(page 2 java EE is said to be geared towards developing large-scale, distributed networking applications and web-based applications)
- C (page 16 was implemented in 1972 by Denis Ritchie at Bell Laboratories)
- ?
- C++ (page 17 an extension of C, improves on C and provides for OOP )
Exercise 1.6 Fill in the blanks in each of the following statements:
- Java programs normally go through five phases ____,____,_____,____ and _____.
- 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.
- The command java invokes the_____, which executes Java programs.
- A(n) ______ is a software application that simulates a computer, but hides the underlying operating system and hardware from the programs that interact with it.
- The _____ takes the .class files containing the program’s bytecodes and transfers them to primary memory.
- The _____ examines bytecodes to ensure that they’re valid.
- i)edit
- ii)compile
- iii)load
- iv)verify
- v)execute
- IDE(Integrated Development Environment) (tbk page 19 )
- JVM(Java Virtual Machine page 20 the java compiler translates java source code into bytecodes and bytecodes are executed by the JVM-The JVM is invoked by the java command)
- Virtual Machine(VM page 20)
- The JVM's class loader(page 20)
- Bytecode verifier(page 21)
- Explain the two compilation phases of Java programs.
Exercise 1.7 :
- a) In the 1st phase, the source code(filename.java) is translated into bytecodes(using the java compiler with the javac +filename.java command )
- b)In the second phase, during execution, the JVM is invoked using the java command accompanied by the filename(seems like without the extension) this translates the bytecodes into machine language for the actual computer on which the code executes.
- You’re probably wearing on your wrist one of the world’s most common types of objects— a watch. Discuss how each of the following terms and concepts applies to the notion of a watch: object, attributes, behaviors, class, inheritance (consider, for example, an alarm clock), abstraction, modeling, messages, encapsulation, interface and information hiding.
Exercise 1.8 :
- a)Object :-
A watch is constituted of different part which together join to give us a view of what the time at a given moment is.
It is only when these parts are combined together that you can have what is called a watch .
The individual components are usually design and as it is in most cases, this will begin in the form of engineering drawings or blueprints
Depending on whether we will use a mechanical or an electronic watch, we will have to make different design for the power source location, the watch casing, the hands, the watch protection.
The main thing the user ever check out from the watch is the position of its hands to read time. The rest of the watch's functioning is encapsulated within its casing and these complex mechanisms are kept away from the user of the watch. All this is done such that people who has little or no knowledge on watch mechanisms have no problem in using watches.
The same analogy shall then follow that just as you cannot sleep in the blueprint of a bed, you cannot also read time from the engineering drawings of a watch. Before you can read time from a watch, it must have been constructed from its engineering drawings or design plans.
- b)Attributes:-
Apart from being able to read time, a watch has attributes such as its color, its constituent material(for example, quartz, steel), its power source(mechanical, solar, electronic) , extra properties such as water resistant, its size, its ability to keep track of the date and month.
Also , like its capabilities, The watch's attributes are represent part of its design in its engineering diagrams (for example, a watch which functions on solar energy will include solar panels/cells) and as you will use a watch, its given attributes will be carried along with it (the watch).
Every watch will maintain its own attributes . For example, each watch keeps track of time according to how it was set up, but a given watch does not know the time in another watch except if these watches were synchronized to keep an identical record of time.
In a nutshell , each watch has for example its hand reading attributes which represent the time in that watch but not the time in other watches.
- c)Behaviors:-
Considering the fact that behavior and method are similar terms.
Hence behaviors house the way(s) in which the watch performs its tasks. For example, for a mechanical watch the behavior/method hides the hand and wheel movement mechanisms from the user of the watch.
- d)Class:-
A class is used to house/embody a set of methods that aid it(the class) in performing the class's tasks.A class can be seen as the blueprints or in the case of our watch , the engineering drawings/design plan from which our watch object is created. It will hence contain methods enabling us to read time, change time and so on.
- e)Inheritance:-
With inheritance, we can possibly from an existing class(parent class), create a new class(child class). The new class absorbs the characteristics of the existing class and possibly add extra and unique characteristics of its own to these inherited characteristics.
Our alarm clock may contain the general watch characteristics such as the hands and the timing parameters but at the same time it may have a extra customized alarm device which emits very loud sounds and contains volume control.
At the same time, the alarm clock may not contain the band which most wrist watches contain.
- f)Abstraction:-
Abstraction is a feature which enables us to easily conceptualize a real world object by removing excess/unnecessary details of the object.
If we take a wrist watch , a pendulum clock, an alarm clock and a mechanical watch and remove a given set of features from each of these different categories of watches, we will come to obtain the general set of features that define each and every watch.
You can get quite a practical explanation of abstraction from this web page Object Oriented Programming Abstraction ,
- g)Modeling:-
Modeling has to do with making a representation of something , typically on a smaller scale. With respect to this definition, coming up with the engineering drawings for a watch should represent modeling.
- h)Messages:-
When you want to calibrate an analogue watch(I see calibration as a method hence the act of calibrating my watch is a method call), rotating the crown sends a message to the minute hand of the watch to rotate and hence move from a given minute to another, consequent movements of the minute hand also cause the hour hand to move and hence, the time reading of the watch changes. The message I sent , which was that I wanted to change time was implemented as a method call on the calibration method.
- i)Encapsulation:-
I will take the case in which I am trying to calibrate my watch from the time readings of another watch. Both watches are objects by calibrating one watch from the reading of another, I am bringing about some form of communication between both watches. One may be able to calibrate one watch from another, but that doesn't mean he will be able to understand the implementation details of the watch. This is because the implementation details of each watch are hidden within the watch in a phenomenon which is similar to encapsulation(i.e. wrapping up attributes and methods into objects).
- j)Interface:-
- k)Information Hiding:-
To use a watch, we do not need to know the core details of its timing mechanisms.(such information is hidden)
No comments:
Post a Comment