Intermediate Java Programming Final Exam Questions - 758 Verified Questions

Page 1


Intermediate Java Programming

Final Exam Questions

Course Introduction

Intermediate Java Programming builds upon foundational Java skills by delving into object-oriented programming principles, collections frameworks, exception handling, file I/O, and GUI development using JavaFX or Swing. This course introduces students to advanced concepts such as multithreading, networking, and design patterns, equipping them with practical experience through coding exercises and projects. By exploring the application of Java in real-world contexts, students will strengthen their problem-solving abilities and prepare for upper-level software development courses or professional programming roles.

Recommended Textbook

Absolute Java 5th Edition by Walter Savitch

Available Study Resources on Quizplus

20 Chapters

758 Verified Questions

758 Flashcards

Source URL: https://quizplus.com/study-set/3975

Page 2

Chapter 1: Getting Started

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) The hardest kind of error to detect in a computer program is a:

A)Syntax error

B)Run-time error

C)Logic error

D)All of the above

Answer: C

Q2) The modulus operator,%,returns the remainder of integer division.

A)True

B)False

Answer: True

Q3) In Java,the equal sign is used as the ___________ operator.

A)increment

B)decrement

C)assignment

D)negation

Answer: C

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

Page 3

Chapter 2: Console Input and Output

Available Study Resources on Quizplus for this Chatper

29 Verified Questions

29 Flashcards

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

Sample Questions

Q1) What does it mean to prompt the user?

Answer: Prompting the user means to display a meaningful message to the user asking for some type of input.An example of prompting the user would be displaying a JOptionPane to ask the user to input their name.

Q2) Which statement or group of statements produces the output: Java programming is fun!

A)System.out.print(Java programming); System.out.print(is fun!);

B)System.out.println(Java programming is fun!);

C)System.out.println("Java programming"); System.out.println(" is fun!");

D)System.out.print("Java programming") System.out.println(" is fun!");

Answer: D

Q3) Echoing input is good programming practice because it can reveal problems in the input.

A)True

B)False Answer: True

Q4) Write ONE Java statement to display your first and last name on two separate lines. Answer: System.out.print("Wally\nWonders");

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

Chapter 3: Flow of Control

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) What is the output of the following code segment? public static void main(String[] args)

{ int x = 5;

System.out.println("The value of x is:" + x); while(x > 0)

{ x++;

}

System.out.println("The value of x is:" + x);

}

Answer: The value of x is 5.The program then enters an infinite loop because the value of x is always greater than 0.

Q2) Not including the break statements within a switch statement results in a syntax error.

A)True

B)False

Answer: False

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

Chapter 4: Defining Classes I

Available Study Resources on Quizplus for this Chatper

44 Verified Questions

44 Flashcards

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

Sample Questions

Q1) Write a Java class that represents a Student with instance variables name,id,and gpa.Include constructors,accessor,mutator and any facilitator methods you may need.

Q2) Java has a way of officially hiding details of a class definition.To hide details,you mark them as _________.

A)public

B)protected

C)private

D)all of the above

Q3) Write a Java method that returns the value of PI,where PI = 3.1415926535.

Q4) Discuss the importance of accessor and mutator methods and how they apply to the abstraction concept.

Q5) Java supports operator overloading.

A)True

B)False

Q6) The Java language supports global variables.

A)True

B)False

Q7) What is the purpose of the new operator?

Q8) Define the terms arguments and parameters.How are they different?

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

Chapter 5: Defining Classes Ii

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) The method trim of the String class trims off:

A)Leading white space

B)Trailing white space

C)Leading and trailing white space

D)Blanks

Q2) The Math method that returns the nearest whole number that is greater than or equal to its argument is:

A)round

B)ceil

C)floor

D)all of the above

Q3) All of the following are wrapper classes except:

A)String

B)Integer

C)Character

D)Double

Q4) Write a statement that creates and initializes a static variable named salesTax to 7.59.

Q5) Write ONE Java statement that computes and displays the value of 2<sup>5</sup>.

Q6) Define boxing and unboxing.

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

Chapter 6: Arrays

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) The name of the sorting algorithm that locates the smallest unsorted value in an array and places it in the next sorted position of the array is called:

A)bubble sort

B)merge sort

C)radix sort

D)selection sort

Q2) The base type of an array may be all of the following but:

A)string

B)boolean

C)long

D)all of these may be a base type of an array.

Q3) What is the output of the following code? int[] numbers = new int[10]; for(int i=0; i < numbers.length; ++i) numbers[i] = i * 2; for(int i=0; i < numbers.length; ++i) System.out.print(numbers[i] / 2 + " "); System.out.println();

Q4) How are arrays tested to see if they contain the same contents?

Q5) Explain what the main methods array parameter,args,is used for.

Page 8

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

Chapter 7: Inheritance

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) A constructor for a derived class begins with an invocation of a constructor for the base class.

A)True

B)False

Q2) Create a test driver to test the functionality of your AlarmClock class created in number 3 above.

Q3) What does the instanceof operator do?

Q4) The keyword extends indicates polymorphism.

A)True

B)False

Q5) Explain what a call to super()does in a constructor of a derived class.

Q6) A method or instance variable modified by protected:

A)can not be accessed by name inside its own class definitions.

B)can not be accessed by name inside any class derived from it.

C)can not be accessed by name in the definition of any class in the same package.

D)can not be accessed by name in any other class (that is,other than classes named in a-c.).

Q7) Explain the modifiers public,protected and private.

Q8) What is an "is a" relationship? How does it apply to the world of objects?

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

Chapter 8: Console Input and Output

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) The clone method return type is:

A)the same as the cloned object

B)Object

C)String

D)none of the above

Q2) Implement the base class in the shoe hierarchy in number 8 above.

Q3) An abstract class must have the modifier ___________ included in the class heading.

A)static

B)abstract

C)final

D)private

Q4) Draw an inheritance hierarchy to represent a shoe object.The base class should have derived classes of Dress Shoes,Tennis Shoes and Boots.

Q5) Describe the limitations of the copy constructor.

Q6) Derive a class named Dress Shoes from the base class created in number 9 above.

Q7) Override the clone method inherited in the Dress Shoes class created in number 10 above.

Q8) What are the advantages of polymorphism?

Q9) Explain the difference between early and late binding. Page 10

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

Chapter 9: Exception Handling

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) What is the purpose of the finally block?

Q2) The finally block contains code to be executed whether or not an exception is thrown in a try block.

A)True

B)False

Q3) If a method does not catch an exception,then it must at least warn programmers that any invocation of the method might possibly throw an exception.This warning is called a/an:

A)Exception handler

B)Throws clause

C)Try block

D)Catch block

Q4) When an exception is thrown,the code in the surrounding try block continues executing and then the catch block begins execution.

A)True

B)False

Q5) The throw operator causes a change in the flow of control.

A)True

B)False

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

Chapter 10: File IO

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) Write a Java method that returns a String representing a file name entered by the user.Use the BufferedReader class to obtain input.

Q2) Use the output stream created in number 11 above to write the String BBC to the file named statistics.dat.

Q3) The method _________ reads a single character from an input stream.

A)readLine()

B)skip()

C)read()

D)close()

Q4) Write a Java statement that creates a stream that provides read/write access to the file named autos.txt.

Q5) The methods of the scanner class do not behave the same when reading from a text file as they do when used to read from the keyboard.

A)True

B)False

Q6) Binary files can be handled more efficiently than text files.

A)True

B)False

Q7) What happens when the method close is invoked on a stream?

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

Chapter 12: Uml and Patterns

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

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

Sample Questions

Q1) The third section of a UML class diagram specifies the:

A)class members

B)class name

C)class methods

D)class modifiers

Q2) Draw a UML class diagram for a class that represents a sphere.

Q3) In a UML class diagram,the tilde (~)indicates:

A)public access

B)protected access

C)private access

D)package access

Q4) The Adaptor pattern transforms one class into a different class without changing the underlying class.

A)True

B)False

Q5) A container is a class whose objects hold multiple pieces of data.

A)True

B)False

Q6) Draw a UML class diagram for a class that represents a savings account.

Q7) Define pseudocode.

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

Chapter 13: Interfaces and Inner Classes

Available Study Resources on Quizplus for this Chatper

32 Verified Questions

32 Flashcards

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

Sample Questions

Q1) Any constant variables defined in an interface must be defined as:

A)public

B)private

C)protected

D)package access

Q2) If an inner class contains non static members,then the class name must be modified by the keyword:

A)Final

B)Static

C)Void

D)Protected

Q3) What are two advantages to using inner classes?

Q4) What are the obligations of a class that implements a specific interface?

Q5) Why does Java only allow the inheritance of only one base class?

Q6) A Java interface is an example of:

A)encapsulation

B)abstraction

C)polymorphism

D)all of the above

Q7) What are the semantics of the Comparable interface?

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

Chapter 14: Generics and the Arraylist Class

Available Study Resources on Quizplus for this Chatper

31 Verified Questions

31 Flashcards

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

Sample Questions

Q1) You can not use the set method to put an element at just any index.

A)True

B)False

Q2) All of the following are methods of the ArrayList class except:

A)clear()

B)resize()

C)contains()

D)trimToSize()

Q3) The definition of a parameterized class is a class with one or more type parameters.

A)True

B)False

Q4) A/An ____________ can change the length while the program is running. A)Array

B)ArrayList

C)Type parameter

D)None of the above

Q5) The Type parameter is always indicated as a T. A)True B)False

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

Chapter 15: Linked Data Structures

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) A deep copy of an object is a copy that has references in common with the original object.

A)True

B)False

Q2) A node contains:

A)data item(s)

B)reference(s)to another node

C)both A and B

D)none of the above

Q3) Redraw the diagram created in number 2 above after inserting a node containing Chattanooga,27.6.

Q4) What is the result of an inorder traversal of the binary search tree created in question 12 above?

Q5) A copy constructor and a clone method should normally make a deep copy whenever possible.

A)True

B)False

Q6) following values in the given order: 7,10,5,12,1,3,9.

Q7) Discuss the differences between a queue and a stack.

Q8) What is the binary search tree storage rule?

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

Chapter 16: Collections and Iterators

Available Study Resources on Quizplus for this Chatper

44 Verified Questions

44 Flashcards

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

Sample Questions

Q1) A ____________ is a data structure for holding elements.

A)Collection

B)Iterator

C)Vector

D)Wildcard

Q2) &lt;T&gt; is a wildcard used to specify a wide range of parameters.

A)True

B)False

Q3) What is the difference between a vector's size and a vector's capacity?

Q4) The method contains(Object o)of the ArrayList class returns a value of type:

A)int

B)char

C)byte

D)boolean

Q5) The difference between the List&lt;T&gt; interface and the Set&lt;T&gt; interface is that the Set&lt;T&gt; interface does not impose an order on its unique elements.

A)True

B)False

Q6) What is the purpose of the Java Iterator interface?

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

Chapter 17: Swing I

Available Study Resources on Quizplus for this Chatper

37 Verified Questions

37 Flashcards

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

Sample Questions

Q1) Write a Java statement to create a menu with the title "Drawing Template".

Q2) A menu item is an object of the class:

A)JMenu

B)JMenuBar

C)JMenuItem

D)none of the above

Q3) The JFrame method setVisible()takes one argument of type:

A)byte

B)boolean

C)int

D)short

Q4) Events and listeners for menu items are handled in exactly the same way as they are for buttons.

A)True

B)False

Q5) A JMenu can not be a menu item in another menu.

A)True

B)False

Q6) Explain the model-view-controller pattern when applied to a typical GUI.

Q7) What is an action listener? What is an action event?

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

Chapter 18: Swing II

Available Study Resources on Quizplus for this Chatper

31 Verified Questions

31 Flashcards

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

Sample Questions

Q1) To by pass implementing all methods in the WindowListener interface,make the window listener a derived class of:

A)WindowEvent

B)ActionEvent

C)WindowAdapter

D)None of the above

Q2) All of the following are methods of the Graphics class except:

A)drawRect

B)fillRect

C)coloredRect

D)fill3DRect

Q3) When using scroll bars,the text is viewed through a ______________ that shows only part of the text at a time.

A)view port

B)text area

C)all of the above

D)none of the above

Q4) A rounded rectangle is a rectangle whose corners have been replaced by arcs.

A)True

B)False

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

Chapter 19: Java Never Ends

Available Study Resources on Quizplus for this Chatper

18 Verified Questions

18 Flashcards

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

Sample Questions

Q1) The Java library that supports database connectivity is called:

A)ODBC

B)CDBC

C)MDBC

D)JDBC

Q2) The sleep method of the Thread class requires one formal parameter that represents the number of:

A)nanoseconds

B)microseconds

C)picoseconds

D)milliseconds

Q3) An InterruptedException is a checked exception.

A)True

B)False

Q4) What is a JavaBean?

Q5) ____________ is an enhancement of simple accessor and mutator methods.

A)Event handling

B)Introspection

C)Persistence

D)None of the above

Page 21

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

Chapter 11: Recursion

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) When defining recursive valued methods you should:

A)Ensure there is no infinite recursion.

B)Ensure each stopping case returns the correct value for that case.

C)Ensure that the final value returned by the method is the correct value.

D)All of the above

Q2) What is a stack overflow?

Q3) Explain how the binary search works.

Q4) What are the criteria you must consider when formulating a recursive solution?

Q5) A recursive solution can be preferable to an iterative solution because:

A)recursive method calls are faster than iterative looping

B)recursive solutions may be easier to understand than iterative ones

C)recursion uses less memory than iteration

D)iteration should be avoided.

Q6) A base case must include a recursive call.

A)True

B)False

Q7) The binary search algorithm has worst-case running time that is logarithmic.

A)True

B)False

Q8) Write an iterative method to print a string backwards.

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

Chapter 20: Applets

Available Study Resources on Quizplus for this Chatper

25 Verified Questions

25 Flashcards

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

Sample Questions

Q1) To use the JApplet class,you must import the ______________ package.

A)java.awt

B)java.lang

C)java.util

D)javax.swing

Q2) Write a complete Java applet that displays the phrase "Welcome to my world!" in the center of the applet.

Q3) HTML is case sensitive.

A)True

B)False

Q4) Images can be embedded within HTML pages.

A)True

B)False

Q5) Create an HTML page for the applet created in number 4 above (the class file is named myApplet.class).

Q6) Create an HTML block that will display "Absolute Java" in the largest standard heading.

Q7) An applet class is normally defined as a derived class of the class JApplet.

A)True

B)False

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

Turn static files into dynamic content formats.

Create a flipbook