466). Which of these packages contain classes and interfaces used for input & output operations of a program?
[A]java.util
[B]java.lang
[C]java.io
[D]all of the mentioned
Show Answer
Correct Answer: java.io
Notes:
Answer: c
Explanation: java.io provides support for input and output operations.
467). Which of these class is not a member class of java.io package?
[A]String
[B]StringReader
[C]Writer
[D]File
Show Answer
Correct Answer: String
Notes:
Answer: a
Explanation: None.
468). Which of these interface is not a member of java.io package?
[A]DataInput
[B]ObjectInput
[C]ObjectFilter
[D]FileFilter
Show Answer
Correct Answer: ObjectFilter
Notes:
Answer: c
Explanation: None.
469). Which of these class is not related to input and output stream in terms of functioning?
[A]File
[B]Writer
[C]InputStream
[D]Reader
Show Answer
Correct Answer: File
Notes:
Answer: a
Explanation: A File describes properties of a file, a File object is used to obtain or manipulate the information associated with a disk file, such as the permissions, time date, and directories path, and to navigate subdirectories.
470). Which of these is specified by a File object?
[A]a file in disk
[B] directory path
[C]directory in disk
[D]none of the mentioned
Show Answer
Correct Answer: directory in disk
Notes:
Answer: c
Explanation: None.
471). Which of these is method for testing whether the specified element is a file or a directory?
[A]IsFile()
[B] isFile()
[C]Isfile()
[D] isfile()
Show Answer
Correct Answer: isFile()
Notes:
Answer: b
Explanation: isFile() returns true if called on a file and returns false when called on a directory.
472). What will be the output of the following Java code?
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File("/java/system");
System.out.print(obj.getName());
}
}
[A]java
[B]system
[C]java/system
[D]/java/system
Show Answer
Correct Answer: system
Notes:
Answer: b
Explanation: obj.getName() returns the name of the file.
Output:$ javac files.java
$ java files
system
473). What will be the output of the following Java program? (Note: file is made in c drive.)
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File("/java/system");
System.out.print(obj.getAbsolutePath());
}
}
[A]java
[B]system
[C] java/system
[D]\java\system
Show Answer
Correct Answer: \java\system
Notes:
Answer: d
Explanation: None.
Output:
$ javac files.java
$ java files
\java\system
474). What will be the output of the following Java program? (Note: file is made in c drive.)
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File("/java/system");
System.out.print(obj.canWrite());
System.out.print(" " + obj.canRead());
}
}
[A]true false
[B] false true
[C]true true
[D]false false
Show Answer
Correct Answer: false false
Notes:
Answer: d
Explanation: None.
Output:
$ javac files.java
$ java files
false false
475). What will be the output of the following Java program? (Note: file is made in c drive.) What will be the output of the following Java program? (Note: file is made in c drive.)
import java.io.*;
class files
{
public static void main(String args[])
{
File obj = new File("/java/system");
System.out.print(obj.getParent());
System.out.print(" " + obj.isFile());
}
}
[A]java true
[B] java false
[C] \java false
[D] \java true
Show Answer
Correct Answer: \java false
Notes:
Answer: c
Explanation: getparent() giver the parent directory of the file and isfile() checks weather the present file is a directory or a file in the disk.
Output:
$ javac files.java
$ java files
\java false