CSC II - Final Exam Review

Ace your homework & exams now with Quizwiz!

33. A method that executes because it is called automatically when an appropriate event occurs is an event ____. A) Responder B) Listener C) handler D) source

C) handler

8. The BufferedWriter class contains a ____ method that uses the current platform's line separator. A) lineSeparator() B) systemSeparator() C) newLine() D) newSeparator()

C) newLine()

9. Any of the file input or output methods in a Java program might throw an exception, so all the relevant code in the class i s placed in a ____ block. A) finally B) throw C) try D) catch

C) try

18. The value you store in memory is lost when the program ends or the computer loses power. This type of storage device is called ____. A) random B) sequential C) volatile D) nonvolatile

C) volatile

16. A(n) ____ is a holding place for bytes that are waiting to be read or written. A) ByteChannel B) FileChannel C) InputStream D) ByteBuffer

D) ByteBuffer

31. The ____ responds to keyboard focus events. A) KeyListener B) ActionListener C) ChangeListener D) FocusListener

D) FocusListener

29. 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

D) Source

4. A ____ is a group of characters that has some meaning. A) record B) file C) byte D) field

D) field

21. A(n) ____ object is an avenue for reading and writing a file. A) buffered B) instant access file C) batch processing D) file channel

D) file channel

10. The String class ____ method accepts an argument that identifies the field delimiter and returns an array of Strings. A) tokens() B) divide() C) tokenize() D) split()

D) split()

26. You can call a JFrame setDefaultCloseOperation() method and use ____ as an argument to remove the JFrame and stop running the program. A) JFrame.EXIT_ON_CLOSE B) WindowConstants.DISPOSE_ON_CLOSE C) WindowConstants.DO_NOTHING_ON_CLOSE D) WindowConstants.HIDE_ON_CLOSE

A) JFrame.EXIT_ON_CLOSE

32. The ____ responds to keyboard events. A) KeyListener B) ActionListener C) ChangeListener D) FocusListener

A) KeyListener

44. A benefit of using threads in Java programs is:____ A) To monitor status of some resource's usage B) Enabling multiple inheritance in Java. C) Ensuring your program will never crash, even with system errors. D) Gives the programmer a simplified method to serve web pages.

A) To monitor status of some resource's usage

20. Random files are also called ____ files. A) direct access B) indirect access C) sequential D) scannable

A) direct access

3. After you create a FileSystem object, you can define a 'Path' object using the ____ method with it. A) getPath() B) createPath() C) setPath() D) getDefault()

A) getPath()

14. The benefit of using a(n) ____ file is the ability to retrieve a specific record from a file directly, without reading through other records to locate the desired one. A) random access B) text C) open D) input

A) random access

12. An array of bytes can be wrapped, or encompassed, into a ByteBuffer using the ByteBuffer ____ method. A) wrap() B) convert() C) export() D) toArray()

A) wrap()

34. When you create a(n) ____, you can group several components, such as JCheckBoxes or JRadioButton, so a user can select only one at a time (exclusivity). A) CheckGroup B) ButtonGroup C) OptionBox D) OptionGroup

B) ButtonGroup

41. Recursion is an alternative form of code flow, essentially replacing this: _____ A) Inheritance B) Iteration C) Abstraction D) Polymorphism

B) Iteration

28. A ____ is a Component used to trigger an action or make a selection when the user clicks it. A) JCheckBox B) JButton C) JLabel D) JcomboBox

B) JButton

35. A ____ is a component that combines a button or an editable field and a drop-down list. A) JCheckBox B) JComboBox C) JButton D) JTextBox

B) JComboBox

22. Each Swing component is a descendant of a_____. A) JFrame B) JComponent C) JButton D) Javax

B) JComponent

25. The Swing classes are part of a more general set of UI programming capabilities that are collectively called the ____. A) JavaX Classes B) Java Foundation Classes C) UI packages D) Java Extension Libraries

B) Java Foundation Classes

6. InputStream and OutputStream are subclasses of the ____ class. A) IO B) Object C) NIO D) File

B) Object

40. Every call to a recursive method does this: _____ A) Increases processing resources and halts the main process thread. B) Reduces the original problem size, getting closer to the base case. C) Instantiates a completely new and separate method to be managed in the OS. D) Segments the recursive method into equally lengthened code.

B) Reduces the original problem size, getting closer to the base case.

45. One way to create threads in a Java program is: ______ A) Inherit the Extender() class B) Use the Runnable interface C) Use the MultiThread interface D) Use the IsRunnable() method

B) Use the Runnable interface

30. The ActionListener interface contains the ____ method specification. A) actionOccured (Action e) B) actionPerformed(ActionEvent e) C) actionEvent(ActionEvent e) D) action(Event e)

B) actionPerformed(ActionEvent e)

42. A recursive method is a method that: _____ A) calls Foundation class methods from older versions of Java B) calls itself, repeatedly C) calls a subclass' method when polymorphism is used D) calls the web server system to draw web controls

B) calls itself, repeatedly

24. If a user enters more characters than specified in the instantiation of a JTextField, the extra characters are______. A) stored for later use B) deleted C) added to the previous JComponent D) included, but hidden

B) deleted

38. Look and feel comprises the elements of design, style, and ____ in any user interface. A) font faces B) functionality C) logistics D) syntactics

B) functionality

7. When you use the BufferedReader class, you must import the ____ package into your program. A) java.nio.file B) java.io C) java.nio D) java.io.input

B) java.io

13. A(n) ____ field is the field in a record that makes the record unique from all others. A) unique B) key C) search D) individual

B) key

19. A ____ is a collection of fields that contain data about an entity. A) file B) record C) table D) sequential access file

B) record

5. A data file can be used as a(n) ____ file when each record is accessed one after another in the order in which it was stored. A) application B) sequential access C) stream D) field

B) sequential access

36. A component can be made available or unavailable by passing true or false to the ____ method. A) getSource() B) setEnabled() C) setSelected() D) setBounds()

B) setEnabled()

47. A practice to ensure threads finish a required method before another thread starts is to use the _____ keyword in the method header. A) exclusion B) synchronized C) blocking D) asynchronization

B) synchronized

46. When a thread is created, it inherits its priority from: _____ A) the interface's super class priority B) the thread that created (its parent thread) C) the operating system running the program D) the Java virtual machine

B) the thread that created (its parent thread)

23. The default behavior of a JFrame is to use _______ format, which divides a container into regions. A) GridLayout B) FlowLayout C) BorderLayout D) no layout

C) BorderLayout

39. All recursive methods must have this characteristic: ______ A) One single base case to always stop the recursive calls. B) No base case is used to stop the recursive calls. C) One or more base cases are used to stop the recursive calls. D) A timed event is used to stop the recursive calls.

C) One or more base cases are used to stop the recursive calls.

2. You can use Java's ____ class to create objects that contain information about files or directories, such as their locations, sizes, creation dates, and whether they even exist. A) Directory B) Property C) Path D) File

C) Path

11. ____ applications require that a record be accessed immediately while a client is waiting. A) Sequential B) Dependent C) Real-time D) Non-random

C) Real-time

43. Once a thread is created (instaniated), it is ready to begin execution and exists in this state:_____ A) New B) Running C) Runnable D) Waiting

C) Runnable

37. Swing components are UI elements such as dialog boxes and buttons. You can usually recognize their names because they begin with ____. A) The letter 'S' B) Swing C) The letter 'J' D) UI

C) The letter 'J'

17. Because the backslash character starts the escape sequence in Java, you must use two ____ in a string that describes a 'Path' in the DOS operating system. A) dashes B) quotes C) backslashes D) periods

C) backslashes

1. Some text files are ____ files that contain facts and figures, such as a payroll file that contains employee numbers, names, and salaries. A) application B) volatile C) data D) program

C) data

15. The ____ method returns the last Path element in a list of pathnames. A) toString() B) getNameCount() C) getFileName() D) getName(int)

C) getFileName()

17) When you create a class by making it inherit from another class, the new class automatically, contains the data fields and ____ of the original class. a) Fonts b) Methods c) Class names d) Arrays

b) Methods

12) Which of the following describes a data type for which only appropriate behaviors are allowed? a) Value-neutral b) Type-safe c) Static d)data-cast

b) Type-safe

18) Arrows used in a ____ to show inheritance relationships extend from the descendant class and point to the original class. a) Method diagram b) UML diagram c) Virtual method call d) Composition

b) UML diagram

2) In a(n) ____, you repeatedly compare pairs of items, swapping them if they are out of order, eventually creating a sorted list. a) range match b) bubble sort c) enhanced for loop d) float sort

b) bubble sort

22) Usually, the subclass constructor only needs to initialize the ____ that are specific to the subclass. a) objects b) data fields c) methods d) constructors

b) data fields

7) The Arrays class ____ method puts a particular value in each element of the array. a) binarySearch b) fill c) equals d) search

b) fill

15) When you place objects in order beginning with the object that has the highest values, you are sorting in ____ order. a) Ascending b) Reverse c) Descending d) lowest

c) Descending

4) When mathematicians use a two-dimensional array, they often call it a ____. a) Grid b) Net c) Matrix d) Mesh

c) Matrix

19) 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

c) Override

1) ____ is the process of arranging a series of objects in some logical order. a) Passing b) Organizing c) Sorting d) Sending

c) Sorting

28) Programmers and analysts sometimes use a graphical language to describe classes and object-oriented processes. This language is called ____. a) pseudocode b) GUI c) UML d) Java

c) UML

52) ____ statements are program statements that can never execute under any circumstances. a) Stagnant b) Error c) Unreachable d) Exception

c) Unreachable

45) If you provide an empty method within an abstract class, the method is an abstract method even if you do not explicitly use the keyword ____ when defining the method. a) virtual b) implements c) abstract d) extends

c) abstract

56) When you use a(n) ____ statement, you state a condition that should be true, and Java throws an AssertionError when it is not. a) if b) boolean c) assert d) exception

c) assert

55) A(n) ____ is a Java language feature that can help you detect logic errors that do not cause a program to terminate, but nevertheless produce incorrect results. a) error checker b) thread c) assertion d) throw statement

c) assertion

62) The memory location known as the ____ is where the computer stores the list of method locations to which the system must return. a) local store b) RAM c) call stack d) fixed partition

c) call stack

51) 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

c) catch

47) A functional interface ____. a) is the same as a package b) can have multiple lambda expressions c) contains only one abstract method d) can only contain effectively final variables

c) contains only one abstract method

43) If you do not specify a package for a class, it is placed in an unnamed ____ package. a) system b) language c) default d) general

c) default

57) If you want to ensure that a user enters numeric data, you should use ____ techniques that provide the means for your program to recover from the mistake. a) error-handling b) looping c) exception-handling d) decision

c) exception-handling

32) You sometimes create an abstract class only so you can ____ it to another class. a) link b) copy c) extend d) abstract

c) extend

27) You can use the ____ modifier with methods when you don't want the method to be overridden. a) override b) access c) final d) and

c) final

54) Programs would be less clear if you had to account for ____ exceptions in every method declaration. a) upthrown b) thrown c) runtime d) checked

c) runtime

36) The Object class ____ method converts an Object into a String that contains information about the Object, like the hashcode of its location in memory. a) equals() b) setType() c) toString() d) speak()

c) toString()

10) In Java, you create an enumerated data type in a statement that uses the keyword ____. a) New b) Sequence c) Collection d) Enum

d) Enum

20) If a programming language does not support ____, the language is not considered object-oriented. a) Syntax b) Applets c) Loops d) Polymorphism

d) Polymorphism

11) Regarding enumerations, the ____ method returns an integer that represents the constant's position in the list of constants; as with arrays, the first position is 0. a) valueAt b) positionOf c) ordinal d) indexOf

d) indexOf

41) A(n) ____ looks much like a class, except that all of its methods (if any) are implicitly public and abstract. a) hash code b) package c) collision d) interface

d) interface

6) With a two-dimensional array, the ____ field holds the number of rows in the array. a) Size b) Capacity c) Row d) length

d) length

30) In most Java classes, the keyword ____ precedes each data field, and the keyword ____ precedes each method. a) public,public b) private,private c) public,private d) private,public

d) private,public

23) You can use the keyword ____ within a method in a derived class to access an overridden method in a base class. a) sub b) this c) protected d) super

d) super

5) How would you create an array name someNumbers that holds three rows and four columns? a) int[][] someNumbers = new int[4][3]; b) int[][] someNumbers = new int[3][4]; c) int[] someNumbers = new int[3][4]; d) double[][] someNumbers = new int[3][4];

b) int[][] someNumbers = new int[3][4];

46) When you create a number of classes that inherit from each other, as well as multiple interfaces that you want to implement with these classes, you often will find it convenient to place these related classes in a(n) ____. a) group b) package c) abstract class d) file

b) package

29) The term ____ means "many forms" or dynamic method lookup. a) inheritance b) polymorphism c) UML d) virtual

b) polymorphism

63) When you catch an Exception object, you can call ____ to display a list of methods in the call stack so you can determine the location of the statement that caused the exception. a) callStackTrace() b) printStackTrace() c) whereIs() d) printStack()

b) printStackTrace()

33) A(n) ____ is not an object, but it points to a memory address. a) abstract class b) reference c) extend d) interface

b) reference

60) In order to use a variable both with a try or catch block and afterward, you must declare the variable before the ____ block begins. a) catch b) try c) main d) finally

b) try

13) int[][] myVals = {{2, 4, 6, 8},{20, 40, 60, 80}}; Using the above two-dimensional array, what is the value of myVals[1][2]? a) 4 b) 60 c) 6 d) 40

b) 60

44) ____ is a calculated number that is used to uniquely identify an object. a) Method binding b) A hash code c) Implicit conversion d) Ad-hoc polymorphism

b) A hash code

8) Programmers often refer to a ____ search as a "divide and conquer" procedure. a) Bubble b) Binary c) Division d) Split

b) Binary

9) 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

a) ArrayList

48) The ____ class represents more serious errors from which your program usually cannot recover. a) Error b) Throwable c) Exception d) Menu

a) Error

16) ____ is a mechanism that enables one class to acquire all the behaviors and attributes of another class. a) Inheritance b) Polymorphism c) Encapsulation d) Overriding

a) Inheritance

35) When you define a class, if you do not explicitly extend another class, your class is an extension of the ____ class. a) Object b) super c) public d) abstract

a) Object

38) Classes, such as the String class, have their own equals() methods that overload the ____ class method. a) Object b) Public c) Abstract d) Child

a) Object

3) An array that you can picture as a column of values, and whose elements you can access using one subscript, is a ____ array. a) Single-dimension b) two-dimensional c) parallel d) column

a) Single-dimension

31) A(n) ____ class is a class that you create only to extend from. a) abstract b) inheritance c) parent d) final

a) abstract

42) When you create a class and use the implements clause to implement an interface but fail to code one of the interface's methods, the compiler error generated indicates that you must declare your class to be ____. a) abstract b) static c) public d) new

a) abstract

14) When you place objects in order beginning with the object that has the lowest value, you are sorting in ____ order. a) ascending b) reverse c) descending d) lowest

a) ascending

21) When you create a class and do not provide a(n) ____, Java automatically supplies you with a default one. a) constructor b) argument c) header d) name

a) constructor

58) Assertions are meant to be helpful in the ____ stage of a program. a) development b) testing c) production d) modeling

a) development

39) If Java did not allow you to ____ classes, you would need to create every part of a program from scratch. a) extend b) override c) abstract d) import

a) extend

53) When you have actions you must perform at the end of a try...catch sequence, you can use a ____ block. a) finally b) catch c) throw d) try

a) finally

34) When you assign a variable or constant of one type to a variable of another type, the behavior is called ____. a) implicit conversion b) referencing c) dynamic method binding d) containing

a) implicit conversion

50) A variable declared within a try or catch block is ____ to that block. a) local b) universal c) public d) unique

a) local

40) The capability to inherit from more than one class is called ____. a) multiple inheritance b) collision c) polyinheritance d) dynamic method binding

a) multiple inheritance

37) Instead of using the automatic toString() method with your classes, it is usually more useful to write your own ____ version of the toString() method that displays some or all of the data field values for the object with which you use it. a) overridden b) protected c) static d) condensed

a) overridden

26) The methods in a subclass can use all of the data fields and methods that belong to its parent, with one exception: ____ members of the parent class are not accessible within a child class's methods. a) private b) public c) final d) protected

a) private

25) Using the keyword ____ provides you with an intermediate level of security between public and private access. a) protected b) this c) super d) secure

a) protected

49) A(n) ____ statement is one that sends an Exception object to a catch block. a) throw b) catch c) optional d) assert

a) throw

59) A(n) ____ clause is used in the method header so that applications that use your methods are notified of the potential for an exception. a) throws b) return c) stack d) exception

a) throws

61) Any ____ block might throw an Exception for which you did not provide a catch block. a) try b) throws c) finally d) Exception

a) try

24) When you employ ____, your data can be altered only by the methods you choose and only in ways that you can control. a) virtual method calls b) polymorphism c) information hiding d) inlining

a) virtual method calls


Related study sets

Mod C - Cybersecurity Threats, Vulnerabilities, and Attacks

View Set

Pharmacology - PrepU Chapter :Antibiotics #1

View Set

Cybersecurity Course 1 Module 2 Questions

View Set

Chapter 44: Assessment of Digestive and Gastrointestinal Function

View Set

Ch 6: Cell Function / Ch 7: Cell Growth & Development

View Set

1. MBJ 1: cranium development, triangles of the neck

View Set

ITN Giraffe Species September 17

View Set

40 Hour RBT Training: (Review 1-4)

View Set

Lifespan growth and development: Chapters 3 & 4

View Set