Docsity

Java Programming, 10th Edition (Joyce Farrell) – Full Practice Exam: 100+ Multiple-Choice, Exams of Information Technology

Toggle sidebar
bg1
Java Programming, 10th Edition (Joyce Farrell) – Full Practice Exam: 100+
Multiple-Choice Questions with Verified Answers & Detailed Rationales | Covers
All Chapters (1–10) | Ideal for Final Exam ReviewJava Programming, 10th
Edition by Joyce Farrell – Comprehensive Practice Test Bank
Chapter 1: Creating Java Programs
Q1: 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
☑ Correct Answer: B – high-level
Rationale: High-level languages use English-like terms to make programming
more accessible to humans. Java is an example of a high-level language. In
contrast, machine language uses binary (1s and 0s), procedural languages execute
a series of procedures, and object-oriented programming focuses on objects
containing data and methods.
Q2: The rules of a programming language constitute its ____________.
• A) syntax
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35

Partial preview of the text

Download Java Programming, 10th Edition (Joyce Farrell) – Full Practice Exam: 100+ Multiple-Choice and more Exams Information Technology in PDF only on Docsity!

Java Programming, 10th Edition (Joyce Farrell) – Full Practice Exam: 100+ Multiple-Choice Questions with Verified Answers & Detailed Rationales | Covers All Chapters (1–10) | Ideal for Final Exam ReviewJava Programming, 10th Edition by Joyce Farrell – Comprehensive Practice Test Bank Chapter 1: Creating Java Programs Q1: 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 ☑ Correct Answer : B – high-level Rationale: High-level languages use English-like terms to make programming more accessible to humans. Java is an example of a high-level language. In contrast, machine language uses binary (1s and 0s), procedural languages execute a series of procedures, and object-oriented programming focuses on objects containing data and methods. Q2: The rules of a programming language constitute its ____________.
  • A) syntax
  • B) logic
  • C) format
  • D) objects ☑ Correct Answer : A – syntax Rationale: Syntax refers to the set of rules that defines the structure of a programming language. Logic refers to the reasoning behind program design, format is a general term, and objects are components of object-oriented programming. Q3: A ____________ translates high-level language statements into machine code.
  • A) programmer
  • B) syntax detector
  • C) compiler
  • D) decipherer ☑ Correct Answer : C – compiler Rationale: A compiler translates high-level programming statements into low- level machine code that the computer can execute. Programmers write the code, while "syntax detector" and "decipherer" are not standard programming terms. Q4: Named computer memory locations are called ____________.

Q6: 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 ☑ Correct Answer : C – object-oriented programming Rationale: Object-oriented programming (OOP) models real-world entities as objects that have attributes (data) and behaviors (methods). Procedural programming focuses on step-by-step procedures, while machine language and command-line systems are not programming paradigms. Q7: The values of an object's attributes are known as its ____________.
  • A) state
  • B) orientation
  • C) methods
  • D) condition ☑ Correct Answer : A – state Rationale: In object-oriented programming, the current values of an object's attributes define its state. Methods define behaviors, while orientation and condition are not standard OOP terms.

Q8: An instance of a class is a(n) ____________.

  • A) method
  • B) procedure
  • C) object
  • D) case ☑ Correct Answer : C – object Rationale: A class is a blueprint or template, and an object is a specific instance created from that class. Methods and procedures define behaviors, not instances. Q9: Java is architecturally ____________.
  • A) neutral
  • B) oriented
  • C) specific
  • D) abstract ☑ Correct Answer : A – neutral Rationale: Java is architecturally neutral because compiled Java bytecode can run on any platform that has a Java Virtual Machine (JVM), making it cross-platform compatible.

Q12: Arguments to methods always appear within ____________.

  • A) parentheses
  • B) double quotation marks
  • C) single quotation marks
  • D) curly braces ☑ Correct Answer : A – parentheses Rationale: In Java, method arguments are always enclosed in parentheses following the method name. Curly braces define code blocks, and quotation marks denote string or character literals. Q13: In a Java program, you must use ____________ to separate classes, objects, and methods.
  • A) commas
  • B) semicolons
  • C) dots
  • D) forward slashes ☑ Correct Answer : C – dots Rationale: The dot operator (.) is used in Java to access members of a class or object. For example, System.out.println() uses dots to separate the class, object, and method.

Q14: All Java applications must have a method named ____________.

  • A) method()
  • B) main()
  • C) java()
  • D) Hello() ☑ Correct Answer : B – main() Rationale: The main() method is the entry point for all Java applications. The JVM starts program execution by calling this method. While other method names are possible, main() is required for application startup. Q15: Nonexecuting program statements that provide documentation are called ____________.
  • A) classes
  • B) notes
  • C) comments
  • D) commands ☑ Correct Answer : C – comments

☑ Correct Answer : D – debugging Rationale: While debugging is important, a program can run (though possibly produce incorrect results) even with logic errors. Coding, compiling, and saving are essential prerequisites for program execution. Q18: The command to execute a compiled Java application is ____________.

  • A) run
  • B) execute
  • C) javac
  • D) java ☑ Correct Answer : D – java Rationale: The java command executes a compiled Java program (bytecode). The javac command compiles source code, while run and execute are not standard Java commands. Q19: You save text files containing Java source code using the file extension ____________.
  • A) .java
  • B) .class
  • C) .txt
  • D) .src ☑ Correct Answer : A – .java Rationale: Java source files use the .java extension. After compilation, the resulting bytecode files use the .class extension. The .txt extension is for plain text files. Q20: Java is architecturally neutral. This means that:
  • A) Java programs are independent of any specific operating system
  • B) Java only runs on Windows
  • C) Java requires a specific processor type
  • D) Java cannot be used for web development ☑ Correct Answer : A – Java programs are independent of any specific operating system Rationale: Java's "Write Once, Run Anywhere" (WORA) capability means compiled Java bytecode can run on any platform with a JVM, without recompilation. Chapter 2: Using Data Q21: A variable can hold more than one value at a time. (True/False)
  • A) True

Rationale: In Java, multiplication (*), division (/), and remainder (%) have higher precedence than addition (+) and subtraction (-). These operations are performed before addition and subtraction unless parentheses override the order. Q24: Primitive types serve as the building blocks for more complex data types, called ____ types.

  • A) integer
  • B) literal
  • C) reference
  • D) data ☑ Correct Answer : C – reference Rationale: Primitive types (int, double, boolean, char, etc.) are the basic data types. Reference types (classes, arrays, interfaces) are built from these primitive types and store references to objects rather than the actual data. Q25: ____ refers to the order in which values are used with operators.
  • A) Associativity
  • B) Initialization
  • C) Declaration
  • D) Floating

☑ Correct Answer : A – Associativity Rationale: Associativity determines the order in which operators of the same precedence are evaluated. For example, most binary operators have left-to-right associativity, while assignment operators have right-to-left associativity. Q26: A ____ data type can hold 14 or 15 significant digits of accuracy.

  • A) double
  • B) float
  • C) char
  • D) boolean ☑ Correct Answer : A – double Rationale: The double data type provides about 15-16 significant decimal digits of precision and is the default choice for floating-point numbers in Java. float provides only about 6-7 significant digits. Q27: You use the ____ data type to hold any single character.
  • A) single
  • B) char
  • C) byte
  • D) float
  • D) precedence ☑ Correct Answer : B – arithmetic Rationale: Arithmetic operators (+, - , *, /, %) perform mathematical calculations on numeric values. These operators are fundamental to performing computations in Java programs. Q30: ____ occurs when both of the operands are integers.
  • A) Data modeling
  • B) Type cast
  • C) Integer division
  • D) Unlike assignment ☑ Correct Answer : C – Integer division Rationale: When both operands of the division operator (/) are integers, Java performs integer division, which truncates (discards) the fractional part. To get floating-point division, at least one operand must be a floating-point type. Q31: The ____ is the type to which all operands in an expression are converted so that they are compatible with each other.
  • A) unifying type
  • B) data type
  • C) numbered
  • D) primitive ☑ Correct Answer : A – unifying type Rationale: Java automatically performs binary numeric promotion to a unifying type when operators have operands of different types. This ensures both operands are compatible before the operation is performed. Q32: A(n) ____ dialog box asks a question and provides a text field in which the user can enter a response.
  • A) question
  • B) JOptPane
  • C) confirm
  • D) input ☑ Correct Answer : D – input Rationale: JOptionPane.showInputDialog() displays a dialog that prompts the user for input and provides a text field for their response. showConfirmDialog() asks yes/no questions, and showMessageDialog() displays information. Q33: Each primitive type in Java has a corresponding class contained in the java.lang package. These classes are called ____ classes.
  • A) wrapper

Q35: You may declare an unlimited number of variables in a statement as long as the variables are ____.

  • A) the same data type
  • B) different data types
  • C) initialized
  • D) local ☑ Correct Answer : A – the same data type Rationale: Multiple variables of the same data type can be declared in a single statement by separating them with commas, such as: int a, b, c;. Variables of different types require separate declaration statements. Chapter 3: Using Methods Q36: Which of the following method declarations is correct for a static method named computeSum() if the method receives two double arguments?
  • A) Public static double, double computeSum()
  • B) Public static void computeSum(double a, double b)
  • C) Public int computeSum(double a, double b)
  • D) Public static int computeSum(double a,b) ☑ Correct Answer : B – Public static void computeSum(double a, double b)

Rationale: The correct method declaration includes: access modifier (public), static keyword, return type (void if no value is returned), method name (computeSum), and parameter list with types (double a, double b). Q37: In the method header public static boolean (int age), age is a(n)____.

  • A) argument
  • B) parameter
  • C) return value
  • D) final value ☑ Correct Answer : B – parameter Rationale: Parameters are variables defined in the method declaration that receive values passed to the method. Arguments are the actual values passed when calling the method. Q38: If a method is written to receive an int parameter, and you pass a double to the method, then the method will _______.
  • A) Work correctly, the double will be promoted to an int
  • B) Work correctly, but the double might lose some data
  • C) Execute but issue a warning
  • D) Not work, an error message will be issued