TEST BANK FOR Java Programming 10th Edition Solution By Farrell 2024/2025 (Solution and Answer Guide)
TEST BANK FOR Java Programming 10th Edition Solution By Farrell 2024/2025 (Solution and Answer Guide) The most basic circuitry-level computer language is ____________. a. machine language b. Java c. high-level language d. C++ Answer: a Feedback: The most basic circuitry-level computer language is machine language. Machine language, or machine code, is the most basic set of instructions a computer can execute. Java and C++ are both high-level languages and are the opposite of circuitry-level computer language. 2. Languages that let you use an easily understood vocabulary of descriptive terms, such as read, write, or add, are known as ____________languages. a. procedural b. high-level c. machine d. object-oriented Answer: b Feedback: High-level languages use English-like terms; Java is an example of a high-level language. Procedural languages are those that run by executing a series of procedures or methods. 2 Machine-level languages do not use English-like terms; they use 1s and 0s. Object-oriented languages are run by declaring and using objects that contain data and methods. 3. The rules of a programming language constitute its ____________. a. syntax b. logic c. format d. objects Answer: a Feedback: The rules of a programming language constitute its syntax. 4. A ____________ translates high-level language statements into machine code. a. programmer b. syntax detector c. compiler d. decipherer Answer: c Feedback: A compiler translates high-level language statements into machine code. A programmer writes high-level language statements but does not translate them. “Syntax detector” and “decipherer” are not terms used in programming. 5. Named computer memory locations are called ____________. a. compilers b. variables c. addresses d. appellations Answer: b Feedback: Named computer memory locations are variables. Compilers translate programming statements into machine language; they are not memory locations. Addresses are unnamed computer memory locations. “Appellations” is not a term used in programming. 6. The individual operations used in a computer program are often grouped into logical units called 3 ____________. a. procedures b. variables c. constants d. logistics Answer: a Feedback: The individual operations used in a computer program are often grouped into logical units called procedures. Variables are named memory locations, and constants are values that do not change; they are not groups of logical operations. “Logistics ”is not a term commonly used in programming. 7. Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of ____________. a. command-line operating systems b. procedural programming c. object-oriented programming d. machine languages Answer: c Feedback: Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of object-oriented programming. 8. The values of an object’s attributes are known as its ____________. a. state b. orientation c. methods d. condition Answer: a Feedback: The values of an object’s attributes are known as its state. 9. An instance of a class is a(n) ____________. 4 a. method b. procedure c. object d. case Answer: c Feedback: An instance of a class is an object. 10. Java is architecturally ____________. a. neutral b. oriented c. specific d. abstract Answer: a Feedback: Java is architecturally neutral. 11. You must compile classes written in Java into ____________. a. bytecode b. source code c. Javadoc statements d. object code Answer: a Feedback: You must compile classes written in Java into bytecode. Source code is the high-level programming statements. Javadoc statements are a type of comment used for documentation. Object code is the low-level code produced when a compiler translates highlevel code. 12. All Java programming statements must end with a ____________. a. period b. comma c. closing parenthesis EMAIL ME: EMAIL ME: Solution and Answer Guide: Farrell, Java Programming 10e, [978-035-767-3423], Chapter 1: Creating Java Programs 5 d. semicolon Answer: d Feedback: All Java programming statements must end with a semicolon. 13. Arguments to methods always appear within ____________. a. parentheses b. double quotation marks c. single quotation marks d. curly braces Answer: a Feedback: Arguments to methods always appear within parentheses. 14. In a Java program, you must use ____________ to separate classes, objects, and methods. a. commas b. semicolons c. dots d. forward slashes Answer: c Feedback: In a Java program, you must use dots to separate classes, objects, and methods. 15. All Java applications must have a method named ____________. a. method() b. main() c. java() d. Hello() Answer: b Feedback: All Java applications must have a method named main(). Although an application could have a method named method(), java(), or Hello(), they are not required method EMAIL ME: 6 names. Hello()also is not a conventional name because methods usually start with a lowercase letter. 16. Nonexecuting program statements that provide documentation are called ____________. a. classes b. notes c. comments d. commands Answer: c Feedback: Nonexecuting program statements that provide documentation are called comments. 17. Java supports three types of comments: ____________, ____________, and Javadoc. a. line, block b. string, literal c. constant, variable d. single, multiple Answer: a Feedback: Java supports line, block, and Javadoc comments. 18. Which of the following is not necessary to do before you can run a Java program? a. coding b. compiling c. saving d. debugging Answer: d Feedback: Although you should debug a program, it can run with bugs—it simply will produce incorrect results. You must code, compile, and save a program before you can run it. 19. The command to execute a compiled Java application is ____________. a. run EMAIL ME: EMAIL ME: 7 b. execute c. javac d. java Answer: d Feedback: The command to execute a compiled Java application is java. The command to compile a program is javac. 20. You save text files containing Java source code using the file extension ____________. a. .java b. .class c. .txt d. .src Answer: a Feedback: You save text files containing Java source code using the file extension .java. Programming Exercises Solutions 1. Is each of the following class identifiers (a) legal and conventional, (b) legal but unconventional, or (c) illegal? a. myClass b. void c. Golden Retriever d. invoice# e. 36542ZipCode f. Apartment g. Fruit h. 8888 i. displayTotal() EMAIL ME: EMAIL ME: Solution and Answer Guide: Farrell, Java Programming 10e, [978-035-767-3423], Chapter 1: Creating Java Programs 8 j. Accounts_Receivable Solution a. myClass (b) Unconventional because class names conventionally start with an uppercase letter b. void (c) Illegal because void is a reserved word c. Golden Retriever (c) Illegal because class names cannot contain a space d. invoice# (c) Illegal because class names cannot contain # e. 36542ZipCode (c) Illegal because class names cannot start with a number f. Apartment (a) Legal and conventional because it is one word, not a reserved word, contains no spaces or special characters, and starts with an uppercase letter g. Fruit (a) Legal and conventional because it is one word, not a reserved word, contains no spaces or special characters, and starts with an uppercase letter h. 8888 (c) Illegal because class names cannot start with a number i. displayTotal() (c) Illegal because class names cannot contain parentheses j. Accounts_Receivable (b) Legal but unconventional because class names do not usually contain an underscore 2. Is each of the following method identifiers (a) legal and conventional, (b) legal but unconventional, or (c) illegal? a. associationRules() b. void() c. Golden Retriever() d. invoice#() e. 36542ZipCode() 9 f. PayrollApp() g. getReady() h. 911() i. displayTotal() j. Accounts_Receivable() Solution a. associationRules() (a) Legal and conventional because it is not a keyword, contains no spaces or special characters, and starts with a lowercase letter b. void() (c) Illegal because void is a keyword c. Golden Retriever() (c) Illegal because method names cannot contain a space d. invoice#() (c) Illegal because method names cannot contain # e. 36542ZipCode() (c) Illegal because method names cannot start with a number f. PayrollApp() (b) Legal but unconventional because method names usually start with a lowercase letter g. getReady() (a) Legal and conventional because it is not a keyword, contains no spaces or special characters, and starts with a lowercase letter h. 911() (c) Illegal because method names cannot start with a number i. displayTotal() (a) Legal and conventional because it is not a keyword, contains no spaces or special characters, and starts with a lowercase letter j. Accounts_Receivable() (b) Legal but unconventional because method names usually start with a lowercase letter and do not contain underscores 3. Name at least three attributes that might be appropriate for each of the following classes: a. RealEstateListing b. Vacation EMAIL ME: EMAIL ME: Solution and Answer Guide: Farrell, Java Programming 10e, [978-035-767-3423], Chapter 1: Creating Java Programs 10 c. CreditCardBill Solution a. RealEstateListing streetAddress, numberOfBedrooms, price b. Vacation lengthInDays, destination, cost c. CreditCardBill creditCardNumber, nameOnAccount, amountDue 4. Name at least three real-life objects that are instances of each of the following classes: a. Song b. CollegeCourse c. Musician Solution a. Song Happy Birthday, Star Spangled Banner, All You Need is Love b. CollegeCourse History 102, English 200, College Algebra c. Musician Yo-Yo Ma, Vladimir Horowitz, Eric Clapton 5. Name at least three classes to which each of these objects might belong: a. myRedBicycle b. friedEgg c. cellPhone Solution a. myRedBicycle Bicycle, Transportation, ExerciseDevice Solution and Answer Guide: Farrell, Java Programming 10e, [978-035-767-3423], Chapter 1: Creating Java Programs 11 b. friedEgg BreakfastItem, EggDish, HighProteinFood c. cellPhone Telephone, CommunicationDevice, ExpensiveItem 6. Write, compile, and test a class that uses four println() statements to display four lines of the lyrics of your favorite song. Save the class as SongL. Solution class SongLyrics { public static void main(String[] args) { Sln("Somewhere over the rainbow"); Sln("Way up high"); Sln("There's a land that I heard of"); Sln("Once in a lullaby"); } } 7. Write, compile, and test a class that uses four println() statements to display, in order, your favorite movie quote, the movie it comes from, the character who said it, and the year of the movie. Save the class as MovieQuoteI. Solution class MovieQuoteInfo { public static void main(String[] args) { Sln("Rosebud,"); Sln("said by Charles Foster Kane"); Sln("in the movie Citizen Kane"); Sln("in 1941."); } } 8. Write, compile, and test a class that displays the pattern shown in Figure 1-26. Save the class as TableAndC. Solution class TableAndChairs { public static void main(String[] args) { Sln(" "); Sln("X X"); Sln("X X"); Sln("X XXXXXXXXXX X"); Sln("XXXXX X X XXXXX"); Solution and Answer Guide: Farrell, Java Programming 10e, [978-035-767-3423], Chapter 1: Creating Java Programs 12 Sln("X X X X X X"); Sln("X X X X X X"); } } 9. Write, compile, and test a class that displays the pattern shown in Figure 1-27. Save the class as T. Solution class Triangle { public static void main(String[] args) { Sln(" "); Sln(" T"); Sln(" TTT"); Sln(" TTTTT"); Sln(" TTTTTTT"); Sln(" TTTTTTTTT"); Sln(" TTTTTTTTTTT"); Sln(" TTTTTTTTTTTTT"); } } 10. Write, compile, and test a class that displays the following statement about comments on two lines: Program comments are nonexecuting statements you add to a file for documentation. Also include the same statement in three different comments in the class; each comment should use one of the three different methods of including comments in a Java class. Save the class as C. Solution class Comments { public static void main(String[] args) { Sln("Program comments are nonexecuting statements "); Sln("you add to a file for documentation."); // Program comments are nonexecuting statements // you add to a file for documentation. /* Program comments are nonexecuting statements you add to a file for documentation. */ /** Program comments are nonexecuting statements you add to a file for documentation. */ } 11. From 1925 through 1963, Burma Shave advertising signs appeared next to highways across the Solution and Answer Guide: Farrell, Java Programming 10e, [978-035-767-3423], Chapter 1: Creating Java Programs 13 United States. There were always four or five signs in a row containing pieces of a rhyme, followed by a final sign that read Burma Shave. For example, one set of signs that has been preserved by the Smithsonian Institution reads as follows: Shaving brushes You'll soon see ’em On a shelf In some museum Burma Shave Find a classic Burma Shave rhyme on the Web, making sure the fifth line is Burma Shave. Write, compile, and test a class that displays the slogan. Save the class as BurmaS. Solution class BurmaShave { public static void main(String[] args) { Sln("Shaving brushes"); Sln("You'll soon see 'em"); Sln("On a shelf"); Sln("In some museum"); Sln("Burma Shave"); } } Debugging Exercises Solutions 1. Each of the following files in the Chapter01 folder in your downloadable student files has syntax and/or logic errors. In each case, determine the problem and fix the errors. After you correct the errors, save each file using the same filename preceded with Fix. For example, DebugO will become FixDebugO. a. DebugO public class DebugOne1 { /* This program displays a greeting public void main(String[] args) { Sln("Hello") } } Solution public class FixDebugOne1 { Solution and Answer Guide: Farrell, Java Programming 10e, [978-035-767-3423], Chapter 1: Creating Java Programs 14 /* This program displays a greeting */ public static void main(String[] args) { Sln("Hello"); } } b. DebugO public class DebugOne2 { /* This program displays some output*/ public static void Main(String[] args) { Sintln("Java programming is fun."); Sintln("Getting a program to work); Sintln(can be a challenge,"); Sintln("but when everything works correctly,"); Sintln(it's very satisfying"); } } Solution public class FixDebugOne2 { /* This program displays some output*/ public static void main(String[] args) { Sln("Java programming is fun."); Sln("Getting a program to work"); Sln("can be a challenge,"); Sln("but when everything works correctly,"); Sln("it's very satisfying"); } } c. DebugO public class DebugOne3 { public static void main(String args) { S1n("Over the river"); S1ntln("and through the woods"); ln("to Grandmother's house we go"); } } Solution public class FixDebugOne3 { public static void main(String[] args)
Connected book
Written for
- Institution
- Java Programming 10th Edition
- Course
- Java Programming 10th Edition
Document information
- Uploaded on
- February 2, 2024
- Number of pages
- 609
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
- java programming
- 10th edition
- solution and answer guide
- 2024
- 2025
-
java programming 10th edition
-
test bank for java programming 10th edition