Bottom of Form Question 1 1. 1. this method in the Thread class is used when a t
ID: 3857327 • Letter: B
Question
Bottom of Form
Question 1
1. 1. this method in the Thread class is used when a thread wants to suspend itself for a specified period of time.
* • • A. wait
* • • B. sleep
* • • C. start
* • • D. run
Question 2
1. 1. this method is defined in the ActionListener interface.
A. event
B. action
C. actionEvent
D. actionPerformed
Question 3
1. 1. this class is useful for changing the size and style of the text drawn with method drawString method.
* A. B. A. Text
* C. D. B. Display
* E. F. C. Font
* G. H. D. TypeFont
Question 4
1. 1. this method needs to be implemented if your class implements the Runnable interface.
* A. B. A. a. start
* C. D. B. run
* E. F. C. execute
* G. H. D. sleep
Question 5
1. 1. this method allows us to specify a class which implements the ActionListener interface.
2. 2. A. addActionListener
B. actionListener
C. add
D. addListener
Question 6
1. 1. this method returns the width and height of your JFrame
A. A. getScreenSize
B. B. getSize
C. C. getWidth
D. D. getHeight
Question 7
1. 1. this method is part of the KeyListener interface
* A. B. A. nextKey
* C. D. B. typed
* E. F. C. keyInput
* G. H. D. keyTyped
2 points
Question 8
1. 1. this class is needed to create a child process.
* A. B. A. Thread
* C. D. B. Child
* E. F. C. Start
* G. H. D. Task
Question 9
1. 1. this is a Java language keyword that allows you to launch or initiate an exception
A. catch
B. makeException
C. throw
D. throws
Question 10
1. 1. this class has methods that can provide information about a keystroke entered by the user.
A. NextLine
B. Event
C. KeyEvent
D. KeyStroke
Question 11
1. 1. This method allows a Container to associate itself with a class which implements the LayoutManger interface
* A. B. A. layout
* C. D. B. addLayout
* E. F. C. setLayout
* G. H. D. add
Question 12
1. 1. Which of the following is NOT an advantage of exception handling?
A. Exception handling improves an application's performance.
B. Exception handling allows a method to defer the handling of its errors to a previously called method.
C. Exception handling improves code organization by separating a method's error handling code from the body of the method.
D. Exception handling allows similar errors to be handled by a single handler.
Question 13
1. 1. This abstract class provides the foundation for many other Java GUI classes like JButton, JTextArea
* A. B. A. JObject
* C. D. B. JComponent
* E. F. C. GuiObject
* G. H. D. JGraphics
Question 14
1. 1. Most of the exceptions related to Input/Output are derived from this exception.
* A. B. A. EofException
* C. D. B. FileNotFoundException
* E. F. C. IOException
* G. H. D. RuntimeException
Question 15
1. 1. Which of the following classes allow you to delete a file?
2. 2. A. FileOutputStream
B. FileInputStream
C. File
D. FilterInputStream
E. DataOutputStream
F. RandomAccessFile
Question 16
1. 1. This Java package deals with Graphical user interfaces. The original approach used platform specific code for drawing objects, but this package provided a more consistent Java approach to implementing components like buttons, drop down boxes, etc.
A. java_graphics
B. awt
C. swing
D. graphics
Question 17
1. 1. This low level abstract class is used for writing a stream of bytes
A. Writer
B. Stream
C. OutputStream
D. Output
Question 18
1. 1. This interface is useful for finding out when a user clicks a button, or hits the Enter key in a JTextField class.
* A. B. A. EnterListener
* C. D. B. TouchListener
* E. F. C. ClickListener
* G. H. D. ActionListener
Question 19
1. 1. This class implements a GUI button
* A. B. A. button
* C. D. B. GuiButton
* E. F. C. JButton
* G. H. D. JPushButton
Question 20
1. 1. Which of the following is true about the following code
2. 2.
A. The program will run and generate the output "RuntimeException"
B. The program aborts with an exception
C. The program will run and generate the output "Exception"
D. The program will run and generate the output "MyError1"
E. A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:void doit throws MyError1
Question 21
1. 1. If you add the following statement to your code:
addMouseListener( xclass );
Which options are possible for xclass ....
check all that apply
A. xclass can be an instance of a class which extends MouseAdapter and xclass can override any of the methods in the MouseListener interface.
B. If the class that this code lives in implements MouseListener, then xclass can be replaced with the java keyword "this".
C. xclass can be an instance of a class which extends the abstract class MouseListener
D. xclass can be an instance of an anonymous class which implements MouseListener
Question 22
1. 1. In the code below, we get a compile error at line 25.
Pick the code which replaces line 25 and fixes this compile error and uses the MyMouseHandler class to process Mouse Clicks.
* A. B. A. this.addMouseListener();
* C. D. B. MyMouseHandler mmh = new MyMouseHandler(); mmh.addMouseListener();
* E. F. C. addMouseListener( new MyMouseHandler());
* G. H. D. addMouseListener(this.JFrame);
Question 23
1. 1. In the following code, someone commented out line 18
What are the consequences of having this line commented out?
1. 2.
* A. B. A. A runtime exception will occur when we exit the constructor, because the system will detect an unconnected MouseListener
* C. D. B. The System will throw an "Unhandled Mouse Click" exception when it discovers that the MouseListener is never connected.
* E. F. C. No Compile error or runtime error. However, when our code executes we will not be informed of Mouse clicks.
* G. H. D. A compile error will result once Eclipse discovers that it has a class that implements MouseListener, but this class is never passed to the system.
Question 24
1. 1. This is a class which implements the LayoutManager interface and has a philosophy of placing components in rows and columns on the screen where the cell size is the same for all components.
* A. B. A. ScreenGridLayout
* C. D. B. TableLayout
* E. F. C. JPanel
* G. H. D. GridLayout
Question 25
1. 1. You can read binary class instances from this Input buffering class.
A. FileInputStream
B. ObjectInputStream
C. DataInputStream
D. InputStream
Question 26
* A. Implementing this interface makes it possible for a class to have a child process associated with it.
* B. C. A. Serializable
* D. E. B. Thread
* F. G. C. Runnable
* H. I. D. Executable
Question 27
1. 1. Calling this method on a thread will allow the thread to begin executing.
A. begin
B. start
C. execute
D. runThread
Question 28
1. 1. Which statement is true about the following code
2. 2.
A. There is a compile error because ObjectOutputStream does not have a constructor which takes a FileOutputStream as it's only parameter.
B. This code will not compile unless we catch the "FileNotFoundException"
C. This will not compile unless the Data class implements the FileWriteable interface
D. A Binary file with the name of file.dat will be created that contains the binary contents of the array "arr"
E. A compile error occurs because the Data class does not implement the methods in the Serializable interface
Question 29
1. 1. This is a class is a Container for other Components.
2. 2. A. JPanel
B. ObjectContainer
C. Package
D. PackageContainer
Question 30
1. 1. This low level abstract class is used for reading a stream of "char"s
A. FileReader
B. InputStream
C. Reader
D. FileInputStream
Question 31
1. 1. On line 6, what happens if you remove the "implements Serializable"
The new line 6 would just be:class Data
* A. B. A. The ObjectOutputStream cannot be written because Data does not implement Serializable. An exception occurs instead.
* C. D. B. A Binary file with the name of file.dat will be created that contains the binary contents of the array "arr"
* E. F. C. There is a compile error because ObjectOutputStream does not have a constructor which takes a FileOutputStream as it's only parameter.
* G. H. D. This code will not compile unless we catch the "FileNotFoundException"
* I. J. E. This will not compile unless the Data class implements the FileWriteable interface
Question 32
1. 1. This method is in the Graphics class and is useful for displaying text on a screen
2. 2. A. drawString
B. text
C. displayString
D. drawListener
Question 33
1. 1. The _____________ contains a Java package which deals with Graphical user interfaces. The _________ uses the platform code (i.e. specific to PC, Mac, Linux) to implement components like buttons, drop down boxes, etc.
Pick the appropriate term to fill in the above blanks.
A. A. Abstract Windowing Toolkit
B. B. Swing software
C. C. Drawing Toolkit
D. D. Bios
Question 34
1. 1. All Exception classes and the Error class are derived from this class
A. Throwable
B. Serializable
C. RuntimeException
D. Exception
Question 35
1. 1. This interface contains no methods. However, implementing this interface in a class makes it possible to write the class to an ObjectOutputStream.
A. Comparable
B. Serializable
C. Streamable
D. Writeable
Question 36
1. 1. Which of the following is true about the following code
2. 2.
A. The program will run and generate the output "MyError1"
B. The program will run and generate the output "RuntimeException"
C. The program aborts with an exception
D. A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:void doit throws MyError1
E. The program will run and generate the output "Exception"
Question 37
1. 1. The following block of code creates a Thread using a Runnable target:
Runnable target = new MyRunnable();Thread myThread = new Thread (target);
Which of the following classes can be used to create the target, so that the preceding code compiles correctly?
* A. B. A. public class MyRunnable extends Object {public void run() {/* Some Code */}}
* C. D. B. public class MyRunnable implements Thread{public void run(){/* Some Code */}}
* E. F. C. public class MyRunnable implements Runnable{public void run() {/* Some Code */}}
* G. H. D. public class MyRunnable extends Runnable{public void run(){ /* Some Code */}}
Question 38
1. 1. You can write binary class instances to this Output buffering class.
A. OutputStream
B. ObjectOutputStream
C. PrintStream
D. FileOutputStream
Question 39
1. 1. This interface is useful for identifying the location of where the user does a mouse click
A. MouseEvent
B. MousePressed
C. MouseListener
D. MouseClick
Question 40
1. 1. This class has methods that allow you to create directories, delete files, and rename files.
A. A. Directory
B. B. FileSystem
C. C. File
D. D. fileSystem
Question 41
1. 1. This class provides useful information about a particular font. For example the height size of the font can be obtained from this class.
* A. B. A. FontMetrics
* C. D. B. FontInfo
* E. F. C. FontSizes
* G. H. D. FontInformation
Question 42
1. 1. This is a class which implements the LayoutManager interface and has a philosophy of placing components into optional regions. These regions are often labeled North, South, Center, etc.
2. 2. A. ToolBarLayout
B. BorderLayout
C. RegionLayout
D. Regions
Question 43
1. 1. This low level abstract class is used for reading a stream of bytes
A. ObjectInputStream
B. Reader
C. InputStream
D. FileInputStream
Question 44
1. 1. If you add the following statement to your code:
addMouseListener( xclass );
What must be true about xclass
A. A. xclass will contain all of the methods defined in the MouseListener interface.
B. B. xclass will extend the class MouseListener
C. C. xclass will be an inner class.
D. D. xclass will contain a MouseListener class inside of it.
Question 45
1. 1. An instance of this class is passed to the paint method. This class has many methods related to drawing.
A. Event
B. Object
C. Graphics
D. Canvas
Question 46
1. 1. This class provides buffering for OutputStreams. This class has a lot of overloaded methods named either print or println.
A. PrintStream
B. Writer
C. WriteStream
D. FileStream
Question 47
1. 1. This low level abstract class is used for writing a stream of "char"s
A. Writer
B. OutputStream
C. WriteStream
D. Output
Question 48
1. 1. This class can be constructed to create a Reader class that is associated with a file open for reading.
A. FileReader
B. Reader
C. File
D. FileInputStream
Question 49
1. 1. Which of the following methods is defined by the Runnable interface?
2. 2. A. start()
B. stop()
C. resume()
D. run()
E. sleep()
Question 50
1. 1. This interface is useful for collecting the user's keystrokes
2. 2. A. Scanner
B. nextLine
C. KeyListener
D. InputListener
Question 51
1. 1. This is an interface that is used for classes which are interested in managing the location and sizes of all of the components in a container.
A. ComponenentListener
B. LayoutListener
C. LayoutManager
D. ComponentManager
Question 52
1. 1. one of the methods in the MouseListener interface
A. mouseDragged
B. mouseMotion
C. mousePressed
D. mouseEvent
Question 53
1. 1. This class can be constructed to create an OutputStream class that is associated with a file open for writing
A. FileWriter
B. File
C. FileOutputStream
D. OutputStream
Question 54
1. 1. This method in the Graphics class can be used to draw a circle
2. 2. A. drawCircle
B. drawOval
C. drawRound
D. paintOval
Question 55
1. 1. This is a class which implements the LayoutManager interface and has a philosophy of placing components left to right. When it runs out of room, it starts a new "row" of components.
A. InputStream
B. RowLayout
C. StreamLayout
D. FlowLayout
Question 56
1. 1. Which statement is true about the following code
2. 2.
A. A. If the file abc.txt exists, this code will read the first string found on the line into the variable "s"
B. B. If the file abc.txt exists, this code will read the first line of text into the variable "s"
C. C. A compile error occurs because this code cannot throw an "IOException"
D. D. A compile error occurs because we need to surround line 10 with try-catch logic to catch a "FileNotFoundException"
Question 57
1. 1. This kind of class cannot be constructed. However, classes derived from this class can be constructed if they override the appropriate methods.
A. A. Implementable class
B. B. Object
C. C. Serializable
D. D. Abstract class
Question 58
1. 1. This class can be constructed to create an InputStream class that is associated with a file open for reading.
A. Input
B. FileInputStream
C. FileReader
D. Stream
Question 59
1. 1. This class can be constructed to create a Writer class that is associated with a file open for writing
A. FileWriter
B. FileOutputStream
C. OutputStream
D. File
Question 60
1. 1. This class is used to create a buffering class for the Reader class. This class contains a method called readLine.
A. BufferedReader
B. Reader
C. ObjectInputStream
D. BufferedInputStream
Question 61
1. 1. All Exceptions derived from this class are considered "Unchecked" and the compiler will not force you to write an special code to deal with this Exception.
A. ArithmeticException
B. RuntimeException
C. Throwable
D. Exception
Question 62
1. 1. This method is called to inform the JVM(Java Virtual Machine) that you would like your paint routine called again.
2. 2. A. onDraw
B. paint
C. invalidate
D. repaint
Question 63
1. 1. This method in the Graphics class can be used to draw a rectangle.
2. 2. A. rectangle
B. drawRectangle
C. drawRect
D. quadralateral
Question 64
1. 1. Pick the proper completion for the following:
You want to know when the mouse was moved or dragged. You will need some class which _______________.
A. implements the MouseDragged interface
B. extends the MouseDraggedAbstract class
C. contains the mouseDrag_or_Move routine.
D. implements the MouseMotionListener interface
Question 65
1. 1. Click here to see the Exceptions Shared Example
What is the output if the user enters in:3
Assume there is no file named non_existent_file
A. NullPointer
B. Exception
C. Array
D. RuntimeException
Question 66
1. 1. Click here to see the Exceptions Shared Example
What is the output if the user enters in:5
A. RuntimeException
B. NullPointer
C. Exception
D. Array
Question 67
1. 1. Click here to see the Exceptions Shared Example
What is the output if the user enters in:4
A. Array
B. NullPointer
C. Exception
D. RuntimeException
Question 68
1. 1. Click here to see the Exceptions Shared Example
What is the output if the user enters in:1
A. RuntimeException
B. NullPointer
C. Array
D. Exception
Question 69
1. 1. Click here to see the Exceptions Shared Example
What is the output if the user enters in:2
A. RuntimeException
B. Exception
C. Array
D. NullPointer
Question 70
1. 1. Click here to see the Exceptions Shared Example
What is the output if the user enters in:0
A. Array
B. RuntimeException
C. NullPointer
D. Exception
Top of Form
Bottom of Form
Exceptions Shared Example
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
Explanation / Answer
1. B. sleep
2. D. action performed
3. D. TypeFont
4. B. run
5. A. addActionListener
6. B. getSize
7. D. keyTyped
8. B. Child
9. C. throw
10. D. KeyStroke
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.