Object-Oriented Programming Chapter Exam Questions - 1208 Verified Questions

Page 1


Object-Oriented Programming

Chapter Exam Questions

Course Introduction

Object-Oriented Programming introduces students to the principles and techniques of object-oriented software development. This course covers fundamental concepts such as classes, objects, inheritance, polymorphism, encapsulation, and abstraction. Students will learn how to design and implement programs using object-oriented languages, focusing on modularity, reusability, and maintainability. Practical assignments and projects provide hands-on experience in applying object-oriented principles to solve real-world programming problems, preparing students for advanced programming and software engineering courses.

Recommended Textbook Java Programming 7th Edition by Joyce Farrell

Available Study Resources on Quizplus 17 Chapters

1208 Verified Questions

1208 Flashcards

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

Page 2

Chapter 1: Creating Java Programs

Available Study Resources on Quizplus for this Chatper

68 Verified Questions

68 Flashcards

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

Sample Questions

Q1) Whenever a method requires multiple arguments, the arguments are always separated with ____.

A) commas

B) periods

C) forward slashes

D) brackets

Answer: A

Q2) Although not a requirement, it is Java standard that class identifiers begin with an uppercase letter and use other uppercase letters to improve readability.

A)True

B)False

Answer: True

Q3) If you modify a class, what are the steps you must take to see your changes in the executing program?

Answer: 1. Save the file with the changes (using the same filename).

2. Compile the class with the javac command. (Actually, you are recompiling the class.)

3. Interpret the class bytecode and execute the class using the java command.

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

Chapter 2: Using Data

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) The term ____ refers to the mathematical accuracy of a value.

A) float data

B) real integers

C) significant digits

D) single-precision floating-point number

Answer: C

Q2) The percent sign is the ____ operator.

A) remainder

B) remaining

C) percentage

D) integer division

Answer: A

Q3) ____ occurs when both of the operands are integers.

A) Data modeling

B) Type cast

C) Integer division

D) Unlike assignment

Answer: C

Q4) A(n) ____________________ is a simple data type.

Answer: primitive type

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

Chapter 3: Using Methods, Classes, and Objects

Available Study Resources on Quizplus for this Chatper

68 Verified Questions

68 Flashcards

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

Sample Questions

Q1) When you think in an object-oriented manner, everything is a(n)

Answer: object

Q2) Application classes frequently instantiate objects that use the objects of other classes.

A)True

B)False

Answer: True

Q3) A(n) ____ causes a value to be sent from a called method back to the calling method.

A) return statement

B) method statement

C) instantiation

D) inheritance relationship

Answer: A

Q4) The interface is the part of a method that the method's client does not see.

A)True

B)False Answer: False

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

Chapter 4: More Object Concepts

Available Study Resources on Quizplus for this Chatper

67 Verified Questions

67 Flashcards

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

Sample Questions

Q1) Object-oriented programmers use the term ____ when a child class contains a field or method that has the same name as one in the parent class.

A) out of scope

B) ambiguous

C) override

D) parent friendly

Q2) When you overload a Java method, you write multiple methods with a shared name. A)True

B)False

Q3) A(n) ____________________ begins immediately after the method declaration and ends at the end of the method.

Q4) Describe and provide an example of overloading.

Q5) It is illegal to declare the same variable name more than once within a block. A)True B)False

Q6) In a Java ____________________ statement, you use a wildcard symbol to represent all the classes in a package.

Q7) A(n) ____________________ is simply a folder that provides a convenient grouping for classes.

Page 6

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

Chapter 5: Making Decisions

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) Why would a programmer use an AND operator when using nested if statements?

Q2) if(qtySold > QUOTA) bonusPay = 50; totalPay = regPay + bonusPay; System.out.println("Your totalPay amount is " + totalPay); Why is the above code incorrect? What would be required to make the code execute correctly?

Q3) > or <

A)relational operator

B)conditional operator

C)Boolean values

D)equality

E)switch statement

F)pipes

G)dual-alternative

H)!

I)AND operator

Q4) Explain the use of the NOT operator.

Q5) Describe how a sequence structure works.

Q6) List and explain the keywords used with the switch statement.

Page 7

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

Chapter 6: Looping

Available Study Resources on Quizplus for this Chatper

72 Verified Questions

72 Flashcards

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

Sample Questions

Q1) public class CompareValues

{ public static void main(String[] args)

{

int a = 10, b = 10, c = 11; boolean compare1 = (++b == a); boolean compare3 = (b++ == c); System.out.println("Compare 1 value = " + compare1); System.out.println("Compare 2 value = " + compare2);

Using the above code, what values will appear in compare1 and compare2 when the println commands execute? Describe how the values of compare1 and compare2 change as the statements are executed.

Q2) Why would a loop with altered user input be considered a type of indefinite loop? Give an example.

Q3) When loops are nested, each pair contains a(n) ____________________ loop and an outer loop.

Q4) The ____________________ loop is the posttest loop used in Java.

Q5) Describe how a loop is controlled by a Boolean expression.

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

Chapter 7: Characters, Strings, and the Stringbuilder

Available Study Resources on Quizplus for this Chatper

73 Verified Questions

73 Flashcards

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

Sample Questions

Q1) Besides Double and Integer, other wrapper classes such as Float and Long also provide ____ methods that convert Strings to the wrapper types.

A) valueOf()

B) toWrapper()

C) parseString()

D) parseDouble()

Q2) Explain what is needed to declare a String variable and provide an example.

Q3) StringBuilder greeting = new StringBuilder("Day 1"); Using the above StringBuilder, create a setCharAt() method that will change the "1" to a "2" in the String "Day 1". Explain how the setCharAt() method operates.

Q4) The ____________________ class contains standard methods for testing the values of characters.

Q5) The ____ method lets you add characters at a specific location within a StringBuilder object.

A) charAt()

B) insert()

C) append()

D) setCharAt()

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

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) How would you use a method that belongs to an object that is part of the array? Use an example and demonstrate with Java code.

Q2) When using parallel arrays, if one array has many possible matches, it is most efficient to place the less common items first so that they are matched right away.

A)True

B)False

Q3) A nonprimitive object

A)array variable

B)reference type

C)elements

D)int

E)Java object names

F)length

G)foreach loop

H)reference types

I)return

Q4) When populating an array with an initialization list, you do not need to use the new keyword or provide an array size. Explain why this is the case.

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

Chapter 9: Advanced Array Concepts

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) Write the statement to declare an ArrayList named myVals with a capacity of 15 items. Explain the importance of capacity when working with an ArrayList.

Q2) The ArrayList class ____ method retrieves an item from a specified location in an ArrayList.

A) extract

B) get

C) peek

D) retrieve

Q3) You can add an item at any point in a(n) ____ container and the array size expands automatically to accommodate the new item.

A) ArrayList

B) Array

C) ResizableArray

D) array

Q4) How can you pass a two-dimensional array to a method?

Q5) A method that receives a two-dimensional array uses two ____________________ pairs following the data type in the parameter list of the method header.

Q6) What is sorting and how are objects organized as a result of being sorted?

Page 11

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

Chapter 10: Introduction to Inheritance

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) Sometimes the superclass data fields and methods are not entirely appropriate for the subclass objects; in these cases, you want to ____ the parent class members.

A) negate

B) overrule

C) override

D) hide

Q2) By convention, a class diagram contains the ____ following each attribute or method.

A) data field

B) argument

C) data type

D) class

Q3) ____ polymorphism is the ability of one method name to work appropriately for different subclass objects of the same parent class.

A) Subtype

B) Name

C) Supertype

D) Override

Q4) What is the process of inlining and how is it accomplished in Java?

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

Chapter 11: Advanced Inheritance Concepts

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) An alternative to multiple inheritance available in Java

A)dynamic method binding

B)collision

C)GregorianCalendar

D)multiple inheritance

E)equals() method

F)-d option

G)java.lang

H)public, static, and final

I)interface

Q2) A concrete class that extends the abstract class Calendar

A)dynamic method binding

B)collision

C)GregorianCalendar

D)multiple inheritance

E)equals() method

F)-d option

G)java.lang

H)public, static, and final

I)interface

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

Chapter 12: Exception Handling

Available Study Resources on Quizplus for this Chatper

65 Verified Questions

65 Flashcards

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

Sample Questions

Q1) What is an Exception class? Give an example.

Q2) How is an Error class different from an Exception class?

Q3) When a program contains multiple catch blocks, how are they handled?

Q4) ____ exceptions are the type that programmers should anticipate and from which programs should be able to recover.

A) Unchecked

B) Runtime

C) Checked

D) Thrown

Q5) When a program contains multiple ____ blocks, they are examined in sequence until a match is found for the type of exception that occurred.

A) throw

B) finally

C) catch

D) try

Q6) When an exception is a checked exception, client programmers are forced to deal with the possibility that an exception will be thrown.

A)True

B)False

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

Chapter 13: File Input and Output

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) After you create a FileSystem object, you can define a Path using the ____ method with it.

A) getPath()

B) createPath()

C) setPath()

D) getDefault()

Q2) Comma-separated values (CSV) is a file format strictly used for working with Java and databases.

A)True

B)False

Q3) ____ is an abstract class used in Java for input and output (IO) operations.

A) System.out

B) Reader

C) System.err

D) OutStream

Q4) You can store data in variables within a program, but this type of storage is temporary.

A)True

B)False

Q5) How can you write the system's newline character to a file in Java?

Page 15

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

Chapter 14: Introduction to Swing Components

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) When setting a JFrame's size, part of the area is unusable because it is consumed by the JFrame's title bar and borders.

A)True

B)False

Q2) What are the four JFrame constructors?

Q3) Within an event-driven program, a component on which an event is generated is the ____ of the event.

A) handler

B) driver

C) listener

D) source

Q4) When a user closes a JFrame by clicking the Close button in the upper-right corner, the default behavior is for the JFrame to close and the application to terminate.

A)True

B)False

Q5) What are some of the decisions you must make when extending a JFrame?

Q6) What type of method must you implement when you register an event listener?

Q7) A(n) ____________________ is the default appearance and behavior of any user interface.

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

Chapter 15: Advanced Gui Topics

Available Study Resources on Quizplus for this Chatper

69 Verified Questions

69 Flashcards

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

Sample Questions

Q1) What is the parent class of JPanel?

A) Object

B) Component

C) JComponent

D) Container

Q2) Write the statement to establish a GridLayout with three horizontal rows and six vertical columns in a Container named myGrid.

Q3) Any component you place on the screen has a vertical, or x-axis, position as well as a horizontal, or y-axis, position in the window.

A)True

B)False

Q4) When you use BorderLayout, you are required to add components into each of the five regions.

A)True

B)False

Q5) What is an adapter class?

Q6) Write the code to create a scroll pane named myScroll that will display an image named scenery with a vertical scroll bar always present and a horizontal scroll bar as needed.

Page 17

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

Chapter 16: Graphics

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) ____ is the amount of space between the bottom of the descent of one line and the top of the characters in the successive line of type.

A) Descent

B) Ascent

C) Leading

D) Height of a line

Q2) The position of a component can be changed by using the ____ method and passing it x- and y-coordinate positions.

A) drawString()

B) setLocation()

C) fillArc()

D) repaint()

Q3) Dimension(Dimension d) creates an instance of Dimension with a width of 0 and a height of 0.

A)True

B)False

Q4) Write the statement to instruct a Graphics object named myGraphic to apply blue paint.

Q5) What parameters does the copyArea() method require?

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

Chapter 17: Applets, Images, and Sound

Available Study Resources on Quizplus for this Chatper

72 Verified Questions

72 Flashcards

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

Sample Questions

Q1) The name of a called applet must be a compiled Java applet with a .class file extension.

A)True

B)False

Q2) ____ contains many commands that allow you to format text on a Web page, import graphic images, and link your page to other Web pages.

A) JApplet

B) HTML

C) Swing

D) Applet

Q3) The first method called in any applet

A)current version of HTML

B)init()

C)start()

D)HTML

E)Applet Viewer

F)tags

G)multimedia

H)applet

I)play()

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.