localBlock在java_Java fianl exam(下)

Which of the following methods is not included in

the model for display handling using the AWT?

A. paint()

B. update()

C. repaint()

*D. main()

By default, which security action is not prevented

for Applets accessed over the Internet?

A. File I/O

*B. Display Graphics or Text

C. Runtime execution of another program

D. Attempts to open a socket to any system except the

host that provided the Applet

When a component is added to an applet at

runtime, which method is used to inform the applet

that it needs to redraw itself?

*A. invalidate()

B. validate()

C. paint()

D. repaint()

There are several security concerns of considerable

importance to users of your Java Applets. Which of

the following is not one of the concerns mentioned

inyour text?

A. What if the class that you downloaded wrote to your

storage drives?

B. What if someone writes a malicious class that reads

personal files?

*C. What if the applet communicates with the web server

from which the applet was launched?

D. What if an applet is coded to erase important files client

computer?

Which of the following interfaces must a Java class

implement to receive notification of button click

events?

*A. ActionListener

B. ButtonListener

C. KeyListener

D. WindowListener

Which of the following HTML tags is used to run a

Java class in a Web page?

*A. 

B. 

C. 

D. 

When creating an Applet, the Applet class must be

a sub-class of which class?

A. java.string.String

B. java.class.Window

C. java.class.Console

*D. java.applet.Applet

Which statement is correct when considering

adding components to your Applet?

*A. You can include any AWT component in your Applet.

B. You can only include Label, TextField and Button.

C. You cannot include graphics that you create.

D. You cannot change the font and color of any

component.

Which type of method can be used in an applet to

define color, font, and size?

A. get

B. listener

C. layout

*D. set

Which of the following is not a basic step followed

when creating and using Java Applets?

*A. Run the applet by typing "java name of class.class".

B. Compile the applet.

C. Design the GUI that you wish to display.

D. Create a class that extends from the Applet class.

An object of which of the following classes can be

registered with a component, such as a button to

receive event notifications?

A. Label

B. Text Field

*C. ActionListener

D. GraphicLayout

Which type of method can be used in an applet to

retrieve values of components?

*A. get

B. listener

C. layout

D. set

When a particular character has been rendered for

display by your applet, the newly rendered

character is represented by a shape. What is this

shaped called?

A. symbol

B. letter

C. character

*D. glyph

Which method is used to paint the graphics in an

applet when it is loaded onto a page for the first

time?

A. destroy( )

*B. init( )

C. main( )

D. stop( )

Which of the following is not a valid approach for

obtaining the color blue?

A. Color.BLUE

B. Color r = new Color(0, 0, 255);

C. Color r = new Color(255);

*D. Color r = new Color("Blue");

Which of the following HTML tags is used for

embedding a Java Applet in an HTML page?

*A. 

B. 

C. 

D. 

Which of the following statements is most

important before running an HTML document with

an embedded Java Applet?

A. Make sure the HTML page has a title.

*B. Make sure you have compiled the class.

C. Make sure the applet has colors.

D. Make sure the HTML page has background colors.

Which one of the following statements correctly

defines a Java Applet?

A. A Java Applet is a stand-alone application.

B. A Java Applet is a console based application.

C. A Java Applet runs only in Microsoft Internet Explorer.

*D. A Java Applet is an application called by other

applications, specifically a Web Browser application.

Which of the following is not part of the event

delegation model?

*A. A label object that displays a message.

B. A component that generates an event object.

C. A listener object that implements a Listener interface

and implements the methods that accept the event object

and execute some code that represents a response to the

user action.

D. The registering of the listener object with the

component.

Which of the following is not a key Applet lifecycle

method?

A. init()

B. start()

*C. paint()

D. stop()

12. Exceptions

What should the programmer do when an error

occurs from one of these three objects:

ThreadDeath, LinkageDeath, or

VirtualMachineError?

A. Write an exception block for these errors.

B. Call the computer manufacturer to report the problem.

C. Report the bug to the online bug list server.

*D. Note that it occurred.

What must be done when throwing an integer as

an exception?

*A. Integers cannot be thrown.

B. Declare integers as throwable.

C. Import the exception class.

D. Encapsulate the integer handler.

When an exception occurs in a try block, what

happens to the code execution in the try block?

A. The finally block is executed next.

B. The exception is thrown.

C. The catch blocks are executed.

*D. The try block is terminated.

What does the programmer have to do to handle a

user-defined exception?

A. Write the exception as a start method.

B. Handle the exception as an error.

C. Write the exception as a part of the Component class.

*D. Handle it no differently than any other checked

exception.

Which of the following statements is correct?

A. A try catch block has one or more try blocks and one or

more catch blocks.

*B. A try catch block has one try block and one or more

catch blocks.

C. A try catch block has one try block and one catch block.

D. A try catch block has one or more try blocks and one

catch block.

What is the purpose of a "try" block?

*A. The try block contains code that may generate an

exception.

B. The try block is used to debug code that has not been

proven and may contain exceptions.

C. The try block is used to catch unwanted types of

objects.

D. The try block throws exceptions in order to test the

exception handling of the system.

When you have statements in your code block that

can throw exceptions, there are several choices for

things you must do. Which one of the following is

not oneof these options?

*A. Do nothing. Ignore the exception

B. Declare the exception

C. Handle the exception

D. Handle, re-throw and declare the exception

What happens when an exception is thrown and is

not caught by any method in the call stack?

A. The exception is handled by the operating system and

the program resumes operation.

*B. The program ends.

C. The call stack must contain a method to catch the

exception.

D. The program prints the exception to the screen and

continues.

What is true of a catch block that reports a

message for a specific type of exception?

*A. The catch block must specify the type of exception it is

designed to catch.

B. The catch block must have code to handle any type of

exception and print the appropriate message.

C. The catch block does not necessarily need to specify the

type of exception. The system will know by the code that is

included in the block.

D. The catch block is followed by a finally block that prints

the message specified by the catch block.

What must be done when you have statements

that can throw exceptions in your code?

A. You must write code to handle the exception.

B. You must include code from the handler class to catch

the exception.

*C. You must declare the exception.

D. You must pass the exception on to the operating

system.

Which of the following is one of the items that a

program should do at the very least when an

exception occurs?

A. Recover the lost data and restore the program to its

former state.

B. Exit the program immediately.

*C. Save all the work.

D. Reboot the operating system.

What must be true when a method throws more

than one type of exception?

A. The method signature must list the exception types and

order they are thrown.

*B. The method signature must list the exception types.

C. The method signature must list the exception types and

number of each exception type anticipated.

D. The method signature must use the keyword multiple in

the signature.

Which of the following is permissible when using

inheritance and overriding?

A. Overriding a parent class method and throwing different

exceptions than the parent class.

B. Overriding a parent class method and throwing an

exception more general than the parent class.

C. Overriding a parent class method and throwing no

exceptions.

*D. Overriding a parent class method and throwing less

exceptions of the same type.

What is an exception?

*A. a representation of an exception condition

B. unexpected code written by the programmer

C. unexpected results after the program has terminated

normally

D. untrusted code such as a virus

What must be done when a method re-throws an

exception?

*A. You must declare the exception in the method

signature.

B. You must first catch the exception with a catch

statement.

C. You must use a subclass of the exception.

D. You must unwind the call stack.

If present, which block of code will be executed

when a try block completes without any

exceptions?

A. main

B. catch

*C. finally

D. return

What is true of Errors and RunTimeExceptions?

A. They must be handled by users at execution.

B. They must be defined in the main method.

*C. They must be designed for and handled in all robust

programs.

D. They are handled by the system and programmers are

not expected to deal with them.

Certain errors are known and expected to occur

during a method's processing, specifically errors in

accessing files, in obtaining network connections,

inreceiving data from a database, in sending instructions

to a database, in actions that occur during the processing

of an applet. Which one of the following is used to

categorize the errors listed above?

A. Java errors

B. code or data errors

C. user-defined errors

*D. standard errors

What must be true when a catch block is to catch

multiple exception classes?

A. The key word polymorphism is used to specify the type

of exceptions included.

*B. The block can use polymorphism to handle many types

of exceptions.

C. Polymorphism allows the block to catch any exception

from the sub-class up to the Exception class.

D. Catching multiple exception objects is not allowed by

Java.

The finally clause is not executed under which one

of the following conditions?

A. The code in the try block executes properly.

*B. The System.exit() method is called within a try or catch

block.

C. The code in the try block includes a break.

D. The code in the try block includes a return.

What is the purpose of the finally block?

A. The block terminates exceptions by printing the

appropriate message to the screen.

B. The block finalizes the exception after all try and catch

blocks have given their input to the finally block.

C. The block is executed only if a catch block cannot be

found.

*D. The block takes care of necessary tasks before a

program terminates unless a System.exit() is called.

How are local variables declared when using try

and catch blocks, if you want to print their values

when an exception occurs?

A. The local variables should be declared in the try block.

B. The local variables should be declared in the catch

block.

*C. The local variables should be declared locally outside

the try and catch blocks.

D. The local variables should be declared in both the try

block and the catch block.

What is the rule used by Java to enforce exception

handling?

*A. declare and handle

B. except and define

C. intentions and exceptions defined

D. hand-off and define

There are two general types of Throwable objects.

Which of the following is one of those objects?

A. Throw object

B. Catch object

C. Handle object

*D. Error object

What is the correct definition of a handler?

A. A section of code in which an exception may occur.

B. A section of code that executes when a button is clicked.

*C. A section of code that identifies the type of exception

object to handle.

D. The main section of code for your class that executes.

13. Files, Streams, Input and Output

Which of the following sink stream classes can

write primitive data types?

A. BufferedOutputStream

*B. DataOutputStream

C. FileOutputStream

D. FilterOutputStream

Which of the following Java keywords must be

used to indicate that the value of an instance

variable should not be serialized with its

associated object?

A. abstract

B. final

*C. transient

D. volatile

Which of the following methods are used in

retrieving object data?

*A. ObjectInputStream

B. ObjectOutputStream

C. InputStream

D. OutputStream

What is a marker interface?

A. An interface that has one method that must be defined

by any class implementing it.

B. An interface that determines if a class can be used as a

superclass.

C. An interface that marks a class as transient.

*D. An interface with no methods that is used to indicate

something about a class of objects, similar to a flag.

Which best describes Serializable?

A. It is an abstract class.

B. It is an an interface with one method.

*C. It is an interface with no methods.

D. It is an abstract class with no defined methods.

To read or write character or textual data to or

from a file, you use a low level FileReader object.

What do you wrap this oject in to improve

perfromance?

*A. BufferedReader

B. FileReader

C. ObjectOutputStream

D. ObjectInputStream

Which of the following best describes the purpose

of the File class?

A. Allows you to read and write to sequential access files.

B. Allows you to read and write to random access files.

*C. Allows you to navigate a local file system and discover

properties of specified files.

D. Allows you to create permanent files on the local file

system.

What is true about the high-level

DataInputStream?

*A. It is a filter stream that can convert input to different

data types.

B. It is a buffered stream.

C. It can act alone without a low-level stream object.

D. It can read objects.

What is the purpose of wrapping a FileReader

object in a BufferedReader object?

*A. Buffering improves the performance of I/O operations.

B. That is the only way you can read in primitive data

types.

C. A FileReader object must take a BufferedReader object

as an argument to its constructor.

D. A BufferedReader allows you to read a byte at a time.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值