0% found this document useful (0 votes)
10 views25 pages

Java How To Program Early Objects 10th Edition Testbank

The document contains sample chapter questions from various topics related to Java programming, including arrays, exception handling, object-oriented programming, and concurrency. Each chapter features multiple-choice questions designed to test knowledge on specific concepts. The content serves as a test bank for students studying Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views25 pages

Java How To Program Early Objects 10th Edition Testbank

The document contains sample chapter questions from various topics related to Java programming, including arrays, exception handling, object-oriented programming, and concurrency. Each chapter features multiple-choice questions designed to test knowledge on specific concepts. The content serves as a test bank for students studying Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

A A

A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
A A
Chapter 7: Arrays and Arraylists

Sample Chapter Questions

Q1) A(n)________ indicates a problem that occurs while a program executes.


A)syntax error
B)omitted import
C)missing semicolon
D)exception

Q2) Which statement correctly passes the array items to method takeArray? Array items
contains 10 elements.
A)takeArray(items[]).
B)takeArray(items).
C)takeArray(items[9]).
D)Arrays cannot be passed to methods-each item must be sent to the method
separately.

Q3) A(n)________ indicates a problem that occurs while a program executes.


A)syntax error
B)omitted import
C)missing semicolon
D)exception

Click Here! Download


Page 2 Testbank Now
Chapter 1: Introduction to Computers and Java

Sample Chapter Questions

Q1) Which of the following statements is false?


A)The command window in Windows is called a Command Prompt.
B)The command window in OS X is called a Terminal.
C)The command window in Linux is called the shell.
D)All of the above are true.

Q2) Which of the following statements is false?


A)Android-the fastest-growing mobile and smartphone operating system-is based on
the Windows kernel and uses Java.
B)Android is open source and free.
C)Android smartphones include the functionality of a mobile phone,Internet client (for
web browsing and Internet communication),MP3 player,gaming console,digital camera
and more.
D)Android handheld devices feature full-color multitouch screens which allow you to
control the device with gestures involving one touch or multiple simultaneous touches.

Click Here! Download Testbank Now

Page 3
Chapter 17: Lambdas

Sample Chapter Questions

Q1) ________ is a method reference for an instance method of a [Link] creates a


one-parameter lambda that invokes the instance method on the lambda's argument
and returns the method's result.
A)Math::sqrt
B)[Link]::println
C)TreeMap::new
D)String::toUpperCase

Q2) Class Arrays provides ________ stream methods for creating


IntStreams,LongStreams and DoubleStreams from int,long and double arrays or from
ranges of elements in the arrays.
A)virtual
B)package
C)overridden
D)overloaded

Click Here! Download Testbank Now

Page 4
Chapter 6: Methods: a Deeper Look

Sample Chapter Questions

Q1) Which of the following statements is false?


A)The Java API consists of packages.
B)The Java API helps programmers avoid "reinventing the wheel."
C)The Java API consists of import declarations.
D)None of the above.

Q2) Method log takes the logarithm of its argument with respect to what base?
A)10
B)e
C)2
D)pi

Q3) Which of the following can be an argument to a method?


A)Constants.
B)Variables.
C)Expressions.
D)All of the above.

Click Here! Download Testbank Now

Page 5
Chapter 11: Exception Handling

Sample Chapter Questions

Q1) Which of the following statements is true?


A)Using existing exceptions makes the program less robust.
B)Always create your own exception classes.
C)Like any other class,an exception class can contain fields and methods.
D)The new exception class should extend RuntimeException if the program should be
required to handle the exception.

Q2) Which of the following statements regarding the throw point of an exception is false?
A)It specifies the point at which the exception must be handled.
B)It is the initial point at which the exception occurs.
C)It is specified as the top row of the method-call stack at the time the exception
occurred.
D)All of the above statements are true.

Click Here! Download Testbank Now

Page 6
Chapter 3: Introduction to Classes and Objects

Sample Chapter Questions

Q1) Which of the following statements is false?


A)You must create an object of class JOptionPane to use its static method
showMessageDialog.
B)JOptionPane method showInputDialog displays an input dialog containing a prompt
and a field (known as a text field)in which a user can enter text.
C)String method format works like method [Link],except that format returns
the formatted String rather than displaying it in a command window.
D)An input dialog allows the user to enter data into a program.

Q2) Reference-type variables (called references)store ________ in memory.


A)the value of an object
B)a copy of an object
C)the location of an object
D)the size of an object

Click Here! Download Testbank Now

Page 7
Chapter 15: Files,streams and Object Serialization

Sample Chapter Questions

Q1) A(n)________ path starts from the directory in which the application began
executing.
A)absolute
B)relative
C)parallel
D)comparative

Q2) Files static method ________ receives a Path and returns a boolean indicating
whether that Path represents a directory on disk.
A)isDiskDirectory
B)isDirectory
C)isFileDirectory
D)isPath

Q3) Which statement regarding Java files is false?


A)Java imposes no structure on a file.
B)Notions like "record" do not exist in Java files.
C)The programmer must structure files to meet the requirements of applications.
D)Records in a Java sequential file are stored in order by record key.

Click Here! Download


Page 8 Testbank Now
Chapter 19: Searching, Sorting and Big O

Sample Chapter Questions

Q1) What is the efficiency of selection sort?


A)O(n2).
B)O(n log n).
C)O(n).
D)O(1).

Q2) What is the term used for binary search's run time?
A)Linear run time.
B)Quadratic run time.
C)Constant run time.
D)Logarithmic run time.

Q3) What is the base case for the recursive merge sort algorithm?
A)Any array that is already sorted.
B)A two-element array.
C)A one-element array.
D)A zero-element array.

Click Here! Download Testbank Now

Page 9
Chapter 12: Gui Components: Part 1

Sample Chapter Questions

Q1) Class Point represents ________.


A)a filled oval
B)an x-y coordinate pair
C)an object used to draw
D)a period in a sentence

Q2) A MouseHandler object implements which two interfaces?


A)MouseListener and MouseActionListener.
B)MouseListener and MouseMotionListener.
C)MouseListener and MouseEventListener.
D)MouseListener only.

Q3) Which of the following choices completes the sentence correctly?


A(n) is a(n).
A)JToggleButton,JCheckBox
B)JToggleButton,JRadioButton
C)JButton,JToggleButton
D)JButton,AbstractButton

Click Here! Download Testbank Now


Page 10
Chapter 2: Introduction to Java Applications

Sample Chapter Questions

Q1) Which of the following is not a valid Java identifier?


A)my Value
B)$_AAA1
C)width
D)m_x

Q2) The format specifier ________ is a placeholder for an int value.


A)%n
B)%d
C)%int
D)%s

Q3) Which of the following is not a compilation error?


A)Neglecting to initialize a local variable in a method before it is used.
B)Placing a semicolon at the end of the first line of an if statement.
C)Omitting the left and right parenthesis for the condition of an if statement.
D)All are compilation errors.

Click Here! Download Testbank Now

Page 11
Chapter 13: Graphics and Java 2D

Sample Chapter Questions

Q1) The Java statement:[Link](290,100,90,55);


A)Draws a filled oval with its center at coordinates x=290,y=100,with height=90 and
width=55.
B)Draws a filled oval with its leftmost point at coordinates x=290,y=100,with height=90
and width=55.
C)Draws a filled oval bounded by a rectangle with its upper-left corner at coordinates
x=290,y=100,with width=90 and height=55.
D)Draws a filled oval bounded by a rectangle with its upper-left corner at coordinates
x=290,y=100,with height=90 and width=55.

Q2) A general path is ________.


A)a set of polylines that do not result in a closed shape
B)a shape constructed from straight lines and complex curves
C)the shape of the curve in a font's characters
D)represented by an object of class GraphicsPath

Click Here! Download Testbank Now

Page 12
Chapter 16: Generic Collections

Sample Chapter Questions

Q1) If no elements are in the Stack,method pop throws an __________.


A)OutOfMemoryError.
B)OutOfMemoryException.
C)EmptyStackError.
D)EmptyStackException.

Q2) Which of the following performs an unboxing conversion? Assume x refers to an


Integer object.
A)int y = x;
B)Integer y = x;
C)Neither of the above.
D)Both of the above.

Q3) Interface Collection contains __________ operations (i.e.,operations performed


on the entire collection).
A)aggregate.
B)composite.
C)integral.
D)bulk.

Click Here! Download


Page 13 Testbank Now
Chapter 14: Strings

Sample Chapter Questions

Q1) Consider the String below:


String r = "a toyota";
Which of the following will create the String r1 = "a TOYOTa"?
A)String r1 = [Link]("toyot",TOYOT");
B)String r1 = [Link]('t','T');
R1 = [Link]('o','0');
R1 = [Link]('y','Y');
C)String r1 = [Link]('t','T').replace('o','0').replace('y','Y');
D)String r1 = [Link](2,4).toUpperCase();

Q2) An anonymous String ________.


A)has no value
B)is a string literal
C)can be changed
D)none of the above

Click Here! Download Testbank Now

Page 14
Chapter 18: Recursion

Sample Chapter Questions

Q1) The recursion step should:


A)check for the base case.
B)call a fresh copy of the recursive method to work on a smaller problem.
C)make two calls to the recursive method.
D)iterate until it reaches a termination condition.

Q2) Fractals that yield an exact copy of the original when a portion of the original image
is magnified are called fractals.
A)strictly self-similar.
B)Koch Curve.
C)similar.
D)mirror.

Q3) Each time a fractal's pattern is applied to it,the fractal is said to be at a new
________.
A)level.
B)depth.
C)order.
D)All of the above.

Click Here! Download


Page 15 Testbank Now
Chapter 20: Generic Classes and Methods

Sample Chapter Questions

Q1) Which statement is false?


A)A generic method may be overloaded.
B)A class can provide two or more generic methods that specify the same method
name but different method parameters.
C)A generic method cannot be overloaded by non-generic methods.
D)When the compiler encounters a method call,it searches for the method declaration
that most precisely matches the method name and the argument types specified in the
call.

Q2) __________ is the default upper bound of a type parameter.


A)String.
B)Comparable.
C)Class.
D)Object.

Click Here! Download Testbank Now

Page 16
Chapter 9: Object Oriented Programming: Inheritance

Sample Chapter Questions

Q1) The default implementation of method clone of Object performs a ________.


A)empty copy.
B)deep copy.
C)full copy.
D)shallow copy.

Q2) Superclass methods with this level of access cannot be called from subclasses.
A)private.
B)public.
C)protected.
D)package.

Q3) To avoid duplicating code,use ________,rather than ________.


A)inheritance,the "copy-and-past" approach.
B)the "copy-and-paste" approach,inheritance.
C)a class that explicitly extends Object,a class that does not extend Object.
D)a class that does not extend Object,a class that explicitly extends Object.

Click Here! Download Testbank Now

Page 17
Chapter 10: Object-Oriented Programming: Polymorphism

Sample Chapter Questions

Q1) Which of the following statements is false?


A)References to interface types do not have access to method toString.
B)Method toString can be invoked implicitly on any object.
C)With inheritance,classes and their inherited classes tend to be very similar.
D)Dramatically different classes can often meaningfully implement the same interface.

Q2) Non-abstract classes are called ________.


A)real classes.
B)instance classes.
C)implementable classes.
D)concrete classes.

Q3) Classes and methods are declared final for all but the following reasons:
A)final methods allow inlining the code.
B)final methods and classes prevent further inheritance.
C)final methods are static.
D)final methods can improve performance.

Click Here! Download Testbank Now

Page 18
Chapter 23: Concurrency

Sample Chapter Questions

Q1) An ExecutorService object is created by calling a static method of which class?


A)Executor.
B)Executors.
C)ExecutorService.
D)Thread.

Q2) Which of the following statements is false?


A)Thread scheduling is XE "platform dependency" platform independent.
B)One simple thread-scheduler implementation keeps the highest-priority thread
running at all times and,if there's more than one highest-priority thread,ensures that all
such threads execute for a quantum each in round-robin fashion.
C)The round-robin process for all highest-priority threads continues until all threads run
to completion.
D)Most programmers who use Java multithreading will not be concerned with setting
and adjusting thread priorities

Click Here! Download Testbank Now

Page 19
Chapter 21: Custom Generic Data Structures

Sample Chapter Questions

Q1) Which is not a typical application of queues?


A)Routing packets in a computer network.
B)File server handling file access requests from many clients.
C)High-speed sorting.
D)Print spooling.

Q2) Which statement is false?


A)In a tightly packed binary tree,each level contains about twice as many elements as
the previous level.
B)When searching a tightly packed 1,000,000-element binary search tree,approximately
20 comparisons need to be made.
C)The level-order traversal of a binary tree visits the nodes of the tree row-by-row
starting at the root node level.
D)Searching a binary tree for a value that matches a key value is slow for loosely packed
trees.

Click Here! Download Testbank Now

Page 20
Chapter 4: Control Statements: Part 1

Sample Chapter Questions

Q1) In Java graphics,coordinate units are measured in ________.


A)pixlets.
B)pixels.
C)points.
D)pikels.

Q2) Which of the following terms is not used to refer to a sentinel value that breaks out of
a while loop?
A)signal value.
B)maximum value.
C)dummy value.
D)flag value.

Q3) Which of the following statements about the conditional operator (?:)is false?
A)The conditional operator is a ternary operator,meaning that it takes three operands.
B)The first operand is a boolean expression.
C)The second operand is the result value if the condition evaluates to false.
D)The second operand is the result value if the condition evaluates to true.

Click Here! Download Testbank Now


Page 21
Chapter 24: Accessing Databases With Jdbc

Sample Chapter Questions

Q1) To obtain data from a table,you ________ the database?


A)select
B)query
C)get
D)None of the above

Q2) Which of the following is a key benefit of using JDBC?


A)It is a simple-to-use database management system.
B)Allows developers to change the underlying database without modifying the Java
code.
C)It is a multi-platform database management system.
D)It provides a GUI for database management systems.

Q3) To retrieve specific columns from a table,use _________ to separate the column
names.
A)(?)
B)*
C) ,
D)-

Click Here! Download


Page 22Testbank Now
Chapter 5: Control Statements: Part 2

Sample Chapter Questions

Q1) Which of the following statements about a do…while repetition statement is true?
A)The body of a do…while loop is executed only if the terminating condition is true.
B)The body of a do…while loop is executed only once.
C)The body of a do…while loop is always executed at least once.
D)None of the above.

Q2) Which of the following can be used in a switch statement in the expression after
keyword case?
a)a constant integral expression.
b)a character constant.
c)a String
d)an enumeration constant.
A)A and B.
B)A and C.
C)B and C.
D)All.

Click Here! Download Testbank Now

Page 23
Chapter 25: JavaFX

Sample Chapter Questions

Q1) The window in which a JavaFX app's GUI is displayed is known as the________.
A)main window
B)stage
C)podium
D)rostrum

Q2) Which of the following statements is false?


A)To display a GUI,you must attach it to a Scene,then attach the Scene to the Stage
that's passed into Application method start.
B)By default,the Scene's size is determined by the size of the scene graph.
C)Overloaded versions of the Scene constructor allow you to specify the Scene's size and
fill (a color,gradient or image).
D)Scene method setTitle specifies the text that appears in the Stage window's title bar.

Click Here! Download Testbank Now

Page 24
Chapter 8: Classes and Objects: a Deeper Look

Sample Chapter Questions

Q1) A final field should also be declared ________ if it is initialized in its declaration.
A)private.
B)public.
C)protected.
D)static.

Q2) Instance variables declared final do not or cannot:


A)Cause syntax errors if used as a left-hand value.
B)Be initialized.
C)Be modified after they are initialized.
D)None of the above.

Q3) When no access modifier is specified for a method or variable,the method or


variable:
A)Is public.
B)Is private.
C)Has package access.
D)Is static.

Click Here! Download Testbank Now


Page 25

You might also like