Search This Blog

Tuesday, February 8, 2011

SCJP 6 Question 25:

Which of the following are true about the File class ? Select two choices.

A. You can perform file I/O operations using its methods.

B. You can find the size of a file using its size() method.

C. You can check if a file exists using its exists() method.

D. You can delete a file using its delete() method.

Answer : C & D

A file class is a abstract representation of file or a directory. You cannot perform any I/O operations using any of the file methods. So option A is incorrect. There is no such method by name size() in File class, to find the size of a file one has to use length() method . So option B is incorrect. exists() and delete() methods exists in File API and they perform the exact functions as mentioned in the Question.

File API for reference.

image

SCJP 6 Question 25:SocialTwist Tell-a-Friend

No comments:

Post a Comment