Solution Manual for Java How To Program, Late Objects, 11th Edition

Solution Manual for Java How To Program, Late Objects, 11th Edition is your guide to textbook mastery, offering detailed solutions to every chapter's exercises.

Grace Turner
Contributor
4.2
39
5 months ago
Preview (16 of 109 Pages)
100%
Purchase to unlock

Page 1

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 1 preview image

Loading page image...

1Introduction to Computers,the Internet and JavaO b j e c t i v e sIn this chapter you’ll:Learn about exciting recentdevelopments in the computerfield.Learn computer hardware,software and networkingbasics.Understand the data hierarchy.Understand the different typesof programming languages.Understand the importance ofJava and other leadingprogramming languages.Understand object-orientedprogramming basics.Learn Internet and web basics.Learn a typical Java program-development environment.Test-drive a Java application.Learn some key recentsoftware technologies.

Page 2

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 2 preview image

Loading page image...

Page 3

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 3 preview image

Loading page image...

2Chapter 1Introduction to Computers, the Internet and JavaSelf-Review Exercises1.1Fill 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 logicunit, 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 arecalled.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 foruse 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.2Fill in the blanks in each of the following sentences about the Java environment:a)Thecommand from the JDK executes a Java application.ANS:java.b)Thecommand from the JDK compiles a Java program.ANS:javac.c)A Java source code file must end with thefile extension.ANS:.java.d)When a Java program is compiled, the file produced by the compiler ends with thefile extension.ANS:.class.e)The file produced by the Java compiler containsthat are executed by the JavaVirtual Machine.ANS:bytecodes.1.3Fill 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 allowedto know how other objects are implemented.ANS:information hiding.b)Java programmers concentrate on creating, which contain fields and the setof 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 viewis called.ANS:object-oriented analysis and design (OOAD).

Page 4

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 4 preview image

Loading page image...

Exercises3d)A new class of objects can be created conveniently by—the new class (calledthe 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 usean industry-standard notation to represent them.ANS:The Unified Modeling Language (UML).f)The size, shape, color and weight of an object are consideredof the object’sclass.ANS:attributes.Exercises1.4Fill in the blanks in each of the following statements:a)The logical unit that receives information from outside the computer for use by thecomputer 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 bythe computer to various devices so that it may be used outside the computer.ANS:The output unit.e)andare 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 programsquickly 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 otherlogical units.ANS:The central processing unit (CPU).1.5Fill in the blanks in each of the following statements:a)Theprogramming 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.

Page 5

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 5 preview image

Loading page image...

4Chapter 1Introduction to Computers, the Internet and Javac)Theensures that messages, consisting of sequentially numbered pieces calledbytes, were properly routed from sender to receiver, arrived intact and were assembledin the correct order.ANS:Transmission Control Protocol (TCP).d)Theprogramming language was developed by Bjarne Stroustrup in the early1980s at Bell Laboratories.ANS:C++.1.6Fill 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 inprograms, and many other features.ANS:integrated development environment (IDE).c)The commandjavainvokes 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)Thetakes the.classfiles containing the program’s bytecodes and transfersthem to primary memory.ANS:class loader.f)Theexamines bytecodes to ensure that they’re valid.ANS:bytecode verifier.1.7Explain the two compilation phases of Java programs.ANS:The two compilation phases that Java programs typically go through include one inwhich source code is translated into bytecodes which are portable across JVMs and asecond in which the bytecodes are translated into machine language for the actualcomputer on which the program executes. In early Java versions, the JVM was simplyan interpreter for Java bytecodes. This caused most Java programs to execute slowlybecause the JVM would interpret and execute one bytecode at a time. Today’s JVMstypically execute bytecodes using a combination of interpretation and so-called just-in-time (JIT) compilation. In this process, The JVM analyzes the bytecodes as theyare 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-languagecode executes.1.8One 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 andinformation hiding.ANS:The entire watch is an object that is composed of many other objects (such as themoving 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 alarmclock). With that in mind, it is possible that a class calledClockcould exist fromwhich other classes such as watch and alarm clock could inherit the basic features in

Page 6

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 6 preview image

Loading page image...

Making a Difference5the clock. The watch is an abstraction of the mechanics needed to keep track of thetime. The user of the watch does not need to know the mechanics of the watch inorder to use it; the user only needs to know that the watch keeps the proper time. Inthis 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 userto 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 thewatch and the member functions (looking at the face to get the time and setting thetime) provide the interface to the data.Making a DifferenceThe 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 thiscan 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 asTerraPasshttp://www.terrapass.com/carbon-footprint-calculator-2/and Carbon Footprinthttp://www.carbonfootprint.com/calculator.aspxprovide 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. Toprepare 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 inthe United States are overweight and about half of those are obese. This causes significant increasesin 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 HealthandHumanServicesprovidesa BMI calculatorathttp://www.nhlbi.nih.gov/guidelines/obesity/BMI/bmicalc.htm. Use it to calculate your own BMI. An exercise in Chapter 3 will ask youto 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’llbegin “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 manyof 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:ManufacturerType 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 drivingEnergy recovery—for example, regenerative breakingCarbon footprint—tons ofCO2per yearFuel capacityCity-miles-per-gallon

Page 7

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 7 preview image

Loading page image...

6Chapter 1Introduction to Computers, the Internet and JavaHighway-miles-per-gallonTwo-mode hybrid propulsion systemEngine size—V6, V8, etc.Vehicle type—SUV, crossover, compact, mid-size, etc.Seating capacityHorse powerDrive train (front wheel drive, all wheel drive)Top speedTorquePrice1.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-specificwords 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 astrange 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 toperform 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 wordin the list. You could accidentally get a word like “woperchild” if you are not carefulabout how you perform replacements. For example, the word “man” can be part ofa larger word, like “woman.” So, replacing every occurrence of “man” can yieldstrange 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 asubsequent 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’sWatson, Amazon’s Alexa, Apple’s Siri, Google’s Google Now and Microsoft’s Cortana. Researchthese 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 greatpromise 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 anydevice and to connect those devices to the Internet. This has led to the notion of the Internet ofThings (IoT), which already interconnects tens of billions of devices. Research the IoT and indicatethe many ways it’s improving people’s lives.

Page 8

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 8 preview image

Loading page image...

Introduction to JavaApplications; Input/Outputand Operators2O b j e c t i v e sIn this chapter you’ll:Write simple Java applications.Use input and outputstatements.Learn about Java’s primitivetypes.Understand basic memoryconcepts.Use arithmetic operators.Learn the precedence ofarithmetic operators.Write decision-makingstatements.Use relational and equalityoperators.

Page 9

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 9 preview image

Loading page image...

2Chapter 2Introduction to Java Applications; Input/Output and OperatorsSelf-Review Exercises2.1Fill in the blanks in each of the following statements:a)A(n)anda(n)begin and end the body of every method.ANS:left brace ({), right brace (}).b)You can use thestatement to make decisions.ANS:if.c)begins an end-of-line comment.ANS://.d),andare called white space.ANS:Space characters, newlines and tabs.e)are reserved for use by Java.ANS:Keywords.f)Java applications begin execution at method.ANS:main.g)Methods,anddisplay information in a command window.ANS:System.out.print,System.out.printlnandSystem.out.printf.2.2State whether each of the following istrueorfalse. Iffalse, explain why.a)Comments cause the computer to display the text after the//on the screen when theprogram executes.ANS:False. Comments do not cause any action to be performed when the program exe-cutes. They’re used to document programs and improve their readability.b)All variables must be given a type when they’re declared.ANS:True.c)Java considers the variablesnumberandNuMbErto be identical.ANS:False. Java is case sensitive, so these variables are distinct.d)The remainder operator(%)can be used only with integer operands.ANS:False. The remainder operator can also be used with noninteger operands in Java.e)The arithmetic operators*,/,%,+and-all have the same level of precedence.ANS:False. The operators*,/and%have higher precedence than operators+and-.f)The identifier_(underscore) is valid in Java 9.ANS:False. As of Java 9,_(underscore) by itself is no longer a valid identifier.2.3Write statements to accomplish each of the following tasks:a)Declare variablesc,thisIsAVariable,q76354andnumberto be of typeintand initializeeach to0.ANS:intc=0;intthisIsAVariable= 0;intq76354=0;intnumber=0;b)Prompt the user to enter an integer.ANS:System.out.print("Enteraninteger:");c)Input an integer and assign the result tointvariablevalue. AssumeScannervariableinputcan be used to read a value from the keyboard.ANS:intvalue=input.nextInt();d)Print"ThisisaJavaprogram"on one line in the command window.Use methodSystem.out.println.ANS:System.out.println("ThisisaJavaprogram");e)Print"This is a Java program"on two lines in the command window. The first lineshould end withJava. Use methodSystem.out.printfand two%sformat specifiers.ANS:System.out.printf("%s%n%s%n","ThisisaJava","program");

Page 10

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 10 preview image

Loading page image...

Self-Review Exercises3f)If the variablenumberis not equal to7, display"Thevariablenumberisnotequalto7".ANS:if(number!= 7){System.out.println("Thevariablenumberisnotequalto7");}2.4Identify and correct the errors in each of the following statements:a)if(c<7);{System.out.println("cislessthan7");}ANS:Error: Semicolon after the right parenthesis of the condition(c<7)in theif. As aresult, the output statement executes regardless of whether the condition in theifistrue.Correction: Remove the semicolon after the right parenthesis.b)if(c=>7){System.out.println("cisequaltoorgreaterthan7");}ANS:Error: The relational operator=>is incorrect.Correction: Change=>to>=.2.5Write declarations, statements or comments that accomplish each of the following tasks:a)State that a program will calculate the product of three integers.ANS://Calculatetheproductofthreeintegersb)Create aScannercalledinputthat reads values from the standard input.ANS:Scannerinput= newScanner(System.in);c)Prompt the user to enter the first integer.ANS:System.out.print("Enterfirstinteger:");d)Read the first integer from the user and store it in theintvariablex.ANS:intx=input.nextInt();e)Prompt the user to enter the second integer.ANS:System.out.print("Entersecondinteger:");f)Read the second integer from the user and store it in theintvariabley.ANS:inty=input.nextInt();g)Prompt the user to enter the third integer.ANS:System.out.print("Enterthirdinteger:");h)Read the third integer from the user and store it in theintvariablez.ANS:intz=input.nextInt();i)Compute the product of the three integers contained in variablesx,yandz,and storethe result in theintvariableresult.ANS:intresult=x*y*z;j)UseSystem.out.printfto display the message"Productis"followed by the value ofthe variableresult.ANS:System.out.printf("Productis%d%n",result);2.6Using the statements you wrote in Exercise 2.5, write a complete program that calculatesand prints the product of three integers.ANS:1//Ex.2.6:Product.java2//Calculatetheproductofthreeintegers.3importjava.util.Scanner; //programusesScanner45publicclassProduct{6publicstaticvoid main(String[]args){

Page 11

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 11 preview image

Loading page image...

7//createScannertoobtaininputfromcommandwindow8Scannerinput=new Scanner(System.in);910System.out.print("Enterfirstinteger:");//promptforinput11int x=input.nextInt();//readfirstinteger1213System.out.print("Entersecondinteger:");//promptforinput14int y=input.nextInt();//readsecondinteger1516System.out.print("Enterthirdinteger:");//promptforinput17intz=input.nextInt();//readthirdinteger1819intresult=x*y*z;//calculateproductofnumbers2021System.out.printf("Productis%d%n",result);22}//endmethodmain23}//endclassProductEnterfirstinteger:10Entersecondinteger:20Enterthirdinteger:30Productis60004Chapter 2Introduction to Java Applications; Input/Output and OperatorsExercisesNOTE: Solutions to the programming exercises are located in thech02solutionsfolder.Each exercise has its own folder namedex02_##where##is a two-digit number representingthe exercise number. For example, Exercise 2.14’s solution is located in the folderex02_14.2.7Fill in the blanks in each of the following statements:a)are used to document a program and improve its readability.ANS:Comments.b)A decision can be made in a Java program with a(n).ANS:ifstatement.c)Calculations are normally performed bystatements.ANS:assignment statements.d)The arithmetic operators with the same precedence as multiplication areand.ANS:division (/), remainder (%)e)When parentheses in an arithmetic expression are nested, theset of paren-theses is evaluated first.ANS:innermost.f)A location in the computer’s memory that may contain different values at various timesthroughout the execution of a program is called a(n).ANS:variable.2.8Write Java statements that accomplish each of the following tasks:a)Display the message"Enteraninteger: ", leaving the cursor on the same line.ANS:System.out.print("Enteraninteger:" );b)Assign the product of variablesbandcto theintvariablea.ANS:=a=b*c;c)Use a comment to state that a program performs a sample payroll calculation.ANS://Thisprogramperformsasimplepayrollcalculation.2.9State whether each of the following istrueorfalse. Iffalse, explain why.

Page 12

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 12 preview image

Loading page image...

Exercises5a)Java operators are evaluated from left to right.ANS:False. Some operators (e.g., assignment,=) evaluate from right to left.b)The following are all valid variable names:_under_bar_,m928134,t5,j7,her_sales$,his_$account_total,a,b$,c,zandz2.ANS:True.c)A valid Java arithmetic expression with no parentheses is evaluated from left to right.ANS:False. The expression is evaluated according to operator precedence.d)The following are all invalid variable names:3g,87,67h2,h22and2h.ANS:False. Identifierh22is a valid variable name.2.10Assuming thatx=2andy = 3, what does each of the following statements display?a)System.out.printf("x=%d%n",x);ANS:x=2b)System.out.printf("Valueof%d+%dis%d%n",x,x,(x+x));ANS:Valueof2+2is4c)System.out.printf("x=");ANS:x=d)System.out.printf("%d=%d%n",(x+y),(y+x));ANS:5=52.11Which of the following Java statements contain variables whose values are modified?a)int p=i+j+k+ 7;b)System.out.println("variableswhosevaluesaremodified");c)System.out.println("a=5");d)int value=input.nextInt();ANS:(a), (d).2.12Given thaty = ax3+ 7, which of the following are correct Java statements for this equation?a)int y=a*x*x*x+ 7;b)int y=a*x*x*(x+7);c)int y=(a*x)*x*(x+7);d)int y=(a*x)*x*x+7;e)int y=a*(x*x*x)+7;f)int y=a*x*(x*x+7);ANS:(a), (d), (e)2.13State the order of evaluation of the operators in each of the following Java statements, andshow the value ofxafter each statement is performed:a)int x=7+3*6/ 2-1;ANS:*,/,+,-; Value ofxis15.b)int x=2%2+2* 2-2/ 2;ANS:%,*,/,+,-; Value ofxis3.c)int x=(3*9*(3+(9*3/(3))));ANS:x=(3*9*(3+(9*3/( 3))));45312Value ofxis324.2.19What does the following code print?System.out.printf("*%n**%n***%n****%n*****%n");

Page 13

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 13 preview image

Loading page image...

6Chapter 2Introduction to Java Applications; Input/Output and OperatorsANS:***************2.20What does the following code print?System.out.println("*");System.out.println("***");System.out.println("*****");System.out.println("****");System.out.println("**");ANS:***************2.21What does the following code print?System.out.print("*");System.out.print("***");System.out.print("*****");System.out.print("****");System.out.println("**");ANS:***************2.22What does the following code print?System.out.print("*");System.out.println("***");System.out.println("*****");System.out.print("****");System.out.println("**");ANS:***************

Page 14

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 14 preview image

Loading page image...

Exercises72.23What does the following code print?System.out.printf("%s%n%s%n%s%n","*","***","*****");ANS:*********

Page 15

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 15 preview image

Loading page image...

3Control Statements: Part 1;Assignment,++and--OperatorsO b j e c t i v e sIn this chapter you’ll:Learn basic problem-solvingtechniques.Develop algorithms throughthe process of top-down,stepwise refinement.Use theifandifelseselection statements tochoose between alternativeactions.Use thewhileiterationstatement to executestatements in a programrepeatedly.Use counter-controllediteration and sentinel-controlled iteration.Use the compoundassignment operator and theincrement and decrementoperators.Learn about the portability ofprimitive data types.

Page 16

Solution Manual for Java How To Program, Late Objects, 11th Edition - Page 16 preview image

Loading page image...

Self-Review Exercises2Self-Review Exercises3.1Fill in the blanks in each of the following statements:a)All programs can be written in terms of three types of control structures:,and.ANS:sequence, selection, iteration.b)Thestatement is used to execute one action when a condition is true and an-other when that condition is false.ANS:ifelse.c)Repeating a set of instructions a specific number of times is callediteration.ANS:counter-controlled (or definite).d)When it’s not known in advance how many times a set of statements will be repeated,a(n)value can be used to terminate the iteration.ANS:sentinel, signal, flag or dummy.e)Theis built into Java; by default, statements execute in the order they appear.ANS:sequence structure.f)If the increment operator isto a variable, first the variable is incremented by1, then its new value is used in the expression.ANS:prefixed.g)When the declarationinty=5;is followed by the assignmenty+=3.3;the value ofyis.ANS:8 [Note:You might expect a compilation error on the assignment statement. The JavaLanguage Specification says that compound assignment operators perform an implic-it cast on the right-hand expression’s value to match the type of the variable on theoperator’s left side. So the calculated value5+3.3=8.3is actually cast to theintvalue8.].3.2State whether each of the following istrueorfalse. Iffalse, explain why.a)An algorithm is a procedure for solving a problem in terms of the actions to execute andthe order in which they execute.ANS:True.b)A set of statements contained within a pair of parentheses is called a block.ANS:False. A set of statements contained within a pair of braces ({and}) is called a block.c)A selection statement repeats an action while a condition remains true.ANS:False. An iteration statement specifies that an action is to be repeated while some con-dition remains true.d)A nested control statement appears in the body of another control statement.ANS:True.e)Java provides the arithmetic compound assignment operators+=,-=,*=,/=and%=forabbreviating assignment expressions.ANS:True.f)The primitive types (boolean,char,byte,short,int,long,floatanddouble) are por-table across only Windows platforms.ANS:False. The primitive types (boolean,char,byte,short,int,long,floatanddouble)are portable across all computer platforms that support Java.g)Specifying the order in which statements execute in a program is called program control.ANS:True.h)The unary cast operator(double)creates a temporary integer copy of its operand.ANS:False. The unary cast operator(double)creates a temporary floating-point copy ofits operand.i)Instance variables of typebooleanare given the valuetrueby default.ANS:False. Instance variables of typebooleanare given the valuefalseby default.
Preview Mode

This document has 109 pages. Sign in to access the full document!

Study Now!

XY-Copilot AI
Unlimited Access
Secure Payment
Instant Access
24/7 Support
Document Chat

Document Details

Related Documents

View all