Java Programming Final Test Solutions - 953 Verified Questions

Page 1


Java Programming

Final Test Solutions

Course Introduction

Java Programming introduces students to the fundamental concepts and techniques of object-oriented programming using the Java language. The course covers essential topics such as variables, control structures, arrays, methods, classes, and inheritance, along with the use of Java libraries for building interactive applications. Through hands-on coding exercises and projects, students will develop problem-solving skills, understand best practices in software development, and learn to create robust, maintainable programs. No previous programming experience is required, making this course suitable for beginners and those seeking to strengthen their programming foundation.

Recommended Textbook

Starting Out with Java From Control Structures through Objects 6th Edition by Tony Gaddis

Available Study Resources on Quizplus

17 Chapters

953 Verified Questions

953 Flashcards

Source URL: https://quizplus.com/study-set/1747 Page 2

Chapter 1: Introduction to Computers and Java

Available Study Resources on Quizplus for this Chatper

51 Verified Questions

51 Flashcards

Source URL: https://quizplus.com/quiz/34833

Sample Questions

Q1) Another term for programs is:

A) Hardware

B) Software

C) Firmware

D) Shareware

Answer: B

Q2) The computer can do such a wide variety of tasks because:

A) It can be programmed

B) It is a machine

C) It contains a central processing unit (CPU)

D) It has the ability to connect to the Internet

Answer: A

Q3) A byte is a collection of:

A) Four bits

B) Six bits

C) Eight bits

D) A dollar

Answer: C

To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Java Fundamentals

Available Study Resources on Quizplus for this Chatper

61 Verified Questions

61 Flashcards

Source URL: https://quizplus.com/quiz/34836

Sample Questions

Q1) Which one of the following would contain the translated Java byte code for a program named Demo?

A) Demo.java

B) Demo.code

C) Demo.class

D) Demo.byte

Answer: C

Q2) A variable's scope is the part of the program that has access to the variable.

A)True

B)False

Answer: True

Q3) This is a value that is written into the code of a program.

A) literal

B) assignment statement

C) variable

D) operator

Answer: A

To view all questions and flashcards with answers, click on the resource link above.

Page 4

Chapter 3: Decision Structures

Available Study Resources on Quizplus for this Chatper

64 Verified Questions

64 Flashcards

Source URL: https://quizplus.com/quiz/34824

Sample Questions

Q1) Which of the following correctly tests the char variable chr to determine whether it is NOT equal to the character B?

A) if (chr > 'B')

B) if (chr < 'B')

C) if (chr != 'B')

D) if (chr != "B")

Answer: C

Q2) What will be the value of charges after the following code is executed?

Double charges, rate = 7.00;

Int time = 180;

Charges = time <= 119 ?

Rate * 2 :

Time / 60.0 * rate;

A) 7.00

B) 14.00

C) 21.00

D) 28.00

Answer: C

To view all questions and flashcards with answers, click on the resource link above.

5

Chapter 4: Loops and Files

Available Study Resources on Quizplus for this Chatper

57 Verified Questions

57 Flashcards

Source URL: https://quizplus.com/quiz/34835

Sample Questions

Q1) The increment operator is:

A) ++

B) --

C) *=

D) -=

Q2) This is an item that separates other items.

A) Controller

B) Partition

C) Doorway

D) Delimiter

Q3) A loop that executes as long as a particular condition exists is called a(n)

A) sentinel loop

B) conditional loop

C) count-controlled loop

D) infinite loop

Q4) Each repetition of a loop is known as what?

A) An iteration

B) A cycle

C) An execution

D) A Lap

To view all questions and flashcards with answers, click on the resource link above. Page 6

Chapter 5: Methods

Available Study Resources on Quizplus for this Chatper

60 Verified Questions

60 Flashcards

Source URL: https://quizplus.com/quiz/34823

Sample Questions

Q1) You should always document a method by writing comments that appear:

A) just before the method's definition

B) just after the method's definition

C) at the end of the file

D) only if the method is more than five lines long

Q2) If method A calls method B, and method B calls method C, and method C calls method D, when method D finishes, what happens?

A) Control is returned to method A.

B) Control is returned to method B.

C) Control is returned to method C.

D) The program terminates.

Q3) Breaking a program down into small manageable methods:

A) makes problems more easily solved

B) allows for code reuse

C) simplifies programs

D) all of the above

Q4) In the method header, the method modifier public means that the method belongs to the class, not a specific object.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: A First Look at Classes

Available Study Resources on Quizplus for this Chatper

58 Verified Questions

58 Flashcards

Source URL: https://quizplus.com/quiz/34822

Sample Questions

Q1) When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable.

A)True

B)False

Q2) The scope of a private instance field is:

A) the instance methods of the same class

B) inside the class, but not inside any method

C) inside the parentheses of a method header

D) the method in which they are defined

Q3) A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method.

A)True

B)False

Q4) Which of the following statements will create a reference, str, to the String, "Hello, World"?

A) String str = "Hello, World";

B) string str = "Hello, World";

C) String str = new "Hello, World";

D) str = "Hello, World";

To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: Arrays and the Arraylist Class

Available Study Resources on Quizplus for this Chatper

64 Verified Questions

64 Flashcards

Source URL: https://quizplus.com/quiz/34834

Sample Questions

Q1) This ArrayList class method deletes an item from an ArrayList.

A) remove

B) delete

C) erase

D) purge

Q2) Which of the following is a correct method header for receiving a two-dimensional array as an argument?

A) public static void passArray(int[2])

B) public static void passArray(int [][])

C) public static void passArray(int[1][2])

D) public static void passArray(int[], int[])

Q3) The String[] args parameter in the main method header allows the program to receive arguments from the operating system command-line.

A)True

B)False

Q4) What does the following statement do? double[] array1 = new double[10];

A) Declares array1 to be a reference to an array of double values

B) Creates an instance of an array of 10 double values

C) Will allow valid subscripts in the range of 0 - 9

D) All of the above

To view all questions and flashcards with answers, click on the resource link above. Page 9

Chapter 8: A Second Look at Classes and Objects

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/34821

Sample Questions

Q1) If a class has a method named finalize, it is called automatically just before a data member that has been identified as final of the class is destroyed by the garbage collector.

A)True

B)False

Q2) The names of the enum constants in an enumerated data type must be enclosed in quotation marks.

A)True

B)False

Q3) You cannot use the fully-qualified name of an enum constant for this.

A) a switch expression

B) an argument to a method

C) a case expression

D) all of these

Q4) The JVM periodically performs this process to remove unreferenced objects from memory.

A) memory sweeping

B) garbage collection

C) memory shuffling

D) system restore

To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 9: Text Processing and More About Wrapper

Classes

Available Study Resources on Quizplus for this Chatper

60 Verified Questions

60 Flashcards

Source URL: https://quizplus.com/quiz/34820

Sample Questions

Q1) You cannot assign a value to a wrapper class object.

A)True

B)False

Q2) In the following statement, what data type must recField be?

Str)getChars(5, 10, recField, 0);

A) String

B) int

C) char

D) char[]

Q3) When using the StringBuilder class's insert method, you can insert:

A) any primitive type

B) a String object

C) a char array

D) All of the above

Q4) The String class's valueOf() method accepts a string representation as an argument and returns its equivalent integer value.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: Inheritance

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

Source URL: https://quizplus.com/quiz/34832

Sample Questions

Q1) A protected member of a class may be directly accessed by:

A) methods of the same class

B) methods of a subclass

C) methods in the same package

D) All of the above

Q2) When declaring class data members, it is best to declare them as:

A) private members

B) public members

C) protected members

D) restricted members

Q3) Every class is either directly or indirectly derived from the Object class.

A)True

B)False

Q4) Private members of the superclass cannot be accessed by the subclass.

A)True

B)False

Q5) In an inheritance relationship, the subclass constructor always executes before the superclass constructor.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 12

Chapter 11: Exceptions and Advanced File IO

Available Study Resources on Quizplus for this Chatper

56 Verified Questions

56 Flashcards

Source URL: https://quizplus.com/quiz/34831

Sample Questions

Q1) The catch clause:

A) follows the try clause

B) starts with the word catch followed by a parameter list in parentheses containing an ExceptionType parameter variable

C) contains code to gracefully handle the exception type listed in the parameter list

D) all of the above

Q2) All of the exceptions that you will handle are instances of classes that extend this class.

A) RunTimeException

B) IOException

C) Error

D) Exception

Q3) When an exception is thrown by a method that is executing under several layers of method calls, a stack trace indicates the method executing when an exception occurred and all of the methods that were called in order to execute that method.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 13

Chapter 12: A First Look at GUI Applications

Available Study Resources on Quizplus for this Chatper

60 Verified Questions

60 Flashcards

Source URL: https://quizplus.com/quiz/34830

Sample Questions

Q1) Which of the following statements is NOT true?

A) Radio buttons are round and check boxes are square.

B) Radio buttons are often grouped together and are mutually exclusive; Check boxes are not.

C) Radio buttons and check boxes both implement the ActionListener interface.

D) They are all true.

Q2) You must use the statement import java.swing.*; in order to use the ItemListener interface.

A)True

B)False

Q3) When this is the argument passed to the JFrame class's setDefaultCloseOperation() method, the application is hidden, but not closed.

A) HIDE_ON_CLOSE

B) JFrame. HIDE_ON_CLOSE

C) JFrame.EXIT_ON_CLOSE

D) JFrame.HIDE_NOT_CLOSE

Q4) Check boxes may be grouped in a ButtonGroup, like radio buttons are.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 14

Chapter 13: Advanced GUI Applications

Available Study Resources on Quizplus for this Chatper

58 Verified Questions

58 Flashcards

Source URL: https://quizplus.com/quiz/34829

Sample Questions

Q1) To force the JFrame that encloses a window to resize itself automatically when a larger object is placed in the frame, use:

A) the pack method

B) the resize method

C) the grow method

D) the enlarge method

Q2) A mnemonic is:

A) A single key on the keyboard that you press to quickly access a component such as a button

B) A key on the keyboard that you press in combination with the SHIFT key to quickly access a component such as a button

C) A key on the keyboard that you press in combination with the ALT key to quickly access a component such as a button

D) A key on the keyboard that you press in combination with the CTRL key to quickly access a component such as a button

Q3) By default the scroll bars are always displayed in a JList component.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above.

15

Chapter 14: Applets and More

Available Study Resources on Quizplus for this Chatper

54 Verified Questions

54 Flashcards

Source URL: https://quizplus.com/quiz/34828

Sample Questions

Q1) An applet does not have to be on a Web server in order to be executed.

A)True

B)False

Q2) Which tag will produce largest text?

A) &lt;h4&gt;Hello&lt;/h4&gt;

B) &lt;h3&gt;Hello&lt;/h3&gt;

C) &lt;h2&gt;Hello&lt;/h2&gt;

D) &lt;h1&gt;Hello&lt;/h1&gt;

Q3) One way of viewing the results of the applet which is invoked in the HTML document TestApplet.html is to enter the following at the command prompt.

A) appletviewer TestApplet.html

B) appleviewer TestApplet

C) viewapplet TestApplet.html

D) view TestApplet

Q4) In the following code, what does getDocumentBase()return?

Play(getDocumentBase(), "mysound.wav");

A) A URL object containing the location of the applet's .class file

B) A URL object containing the location of the HTML file that invoked the applet

C) The HTML location "mysound.wav"

D) The sound file itself

To view all questions and flashcards with answers, click on the resource link above. Page 16

Chapter 15: Creating GUI Applications With Javafx and Scene Builder

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/34827

Sample Questions

Q1) A window in a GUI commonly consists of several ________ that present data to the user and/or allow interaction with the application.

A) modules

B) components

C) elements

D) buttons

Q2) Because only one RadioButton in a toggle group can be selected at any given time, the buttons are said to be this.

A) static components

B) singularly bound

C) all inclusive

D) mutually exclusive

Q3) Like RadioButtons, CheckBoxes may be selected or deselected at run time.

A)True

B)False

Q4) Once you have written and compiled the controller class, you must go back into Scene Builder and register the controller class to the application's GUI.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 17

Chapter 16: Recursion

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

Source URL: https://quizplus.com/quiz/34826

Sample Questions

Q1) Look at the following pseudocode algorithm: algorithm Test14(int x)

If (x < 8)

Return (2 * x)

Else

Return (3 * Test14(x - 8) + 8)

End Test14

What is the base case for the algorithm?

A) x < 8

B) 2 * x

C) 3 * Test14(x - 8) + 8

D) x >= 8

Q2) Recursion can be a powerful tool for solving:

A) basic problems

B) repetitive problems

C) object-oriented problems

D) binary problems

Q3) If method A calls method B, which in turn calls method A, it is called indirect recursion.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 18

Chapter 17: Databases

Available Study Resources on Quizplus for this Chatper

48 Verified Questions

48 Flashcards

Source URL: https://quizplus.com/quiz/34825

Sample Questions

Q1) The columns in a table are assigned SQL data types.

A)True

B)False

Q2) If you wish to sort the results of an SQL query, you can use the ________ clause.

A) SORT BY

B) ALIGN ROW

C) ORDER BY

D) ASCEND

Q3) What is the default concurrency level of a ResultSet object?

A) Public

B) Updatable

C) Private

D) Read-only

Q4) What SQL operator can be used to perform a search for a substring?

A) STR

B) LIKE

C) WHERE

D) SUB

To view all questions and flashcards with answers, click on the resource link above. Page 19

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.