Question: 35 Any of the file input or output methods in a Java program might throw an exception, so all the relevant code in the class

35

Any of the file input or output methods in a Java program might throw an exception, so all the relevant code in the class is placed in a ____ block.

finally
throw
try
catch

36

You specify 2D colors by using the ____ method.

paint()
setPaint()
color()
setColor()

37

Which JFrame JFrame method is used to display the frame?

Display().
Load().
setVisible(true)
show(true)

38

The method __________ sets the font (Helvetica, 20-point bold) in component C.

c.setFont(new Font("Helvetica", Font.bold, 20))
c.setFont(new Font("helvetica", BOLD, 20))
c.setFont(Font("Helvetica", Font.BOLD, 20))
c.setFont(new Font("Helvetica", Font.BOLD, 20))

39

Usually, the subclass constructor only needs to initialize the ____ that are specific to the subclass.

objects
data fields
methods
constructors

40

If graph holds a Graphics object, which of the following puts "CAT" starting at X = 20, Y = 50?

drawString("CAT", 20, 50);
graph.drawString(20, 50, "CAT");
graph.println("CAT");
graph.drawString("CAT", 20, 50);

41

The keyword ____ indicates that a field value is unalterable.

end
final
permanent
static

42

You define the text to be displayed in a tool tip by using the setToolTipText() method and passing an appropriate ____ to it.

Integer
Date
String
Boolean

43

Which of the following most completely describes the steps for setting up event handling for a GUI component?

Create a class that represents the event handler, attach the JFrame to a JWindow object and register the event handler.
Implement an appropriate event-listener interface and register the event handler.
Create a class that represents the event handler and implement an appropriate event-listener interface.
Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.

44

Suppose that the class Mystery is derived from the class Secret. Consider the following statements. Secret secRef = new Secret(); Mystery mysRef = new Mystery(); Which of the following statements is legal in Java? (i) secRef = mysRef; (ii) mysRef = secRef;

Only (i)
Only (ii)
Both (i) and (ii)
None of these

45

Which class do you use to read data from a text file?

File
Formatter
Scanner
Input

46

Which method is used to register a listener object to a button object?

addActionListener
registerButton
eventButton
buttonListener

47

When using the drawRoundRect() method, if you assign ____ to the arc coordinates, the rectangle is not rounded; instead, the corners are square.

-1
0
10
99

48

What happens in a method if there is an exception thrown in a try block but there is no catch block following the try block?

The program ignores the exception.
The program will not compile without a complete try/catch structure.
The program terminates immediately.
The program throws an exception and proceeds to execute the finally block.

49

Which method contains the code that the program executes when a specific event is generated?

buttonListener
GUIListener
actionPerformed
windowListener

50

Given a Graphics object g, to draw an circle with radius 20 centered at (50, 50), you use __________.

g.drawOval(50, 50, 20, 20)
g.drawOval(50, 50, 40, 40)
g.drawOval(30, 30, 20, 20)
g.drawOval(30, 30, 40, 40)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!