多项选择题Which two construct an OutputSream that appends to the file “file.txt”? ()

A. OutputStream out=new FileOutputStream(“file.txt”);
B. OutputStream out=new FileOutputStream(“file.txt”, “append”);
C. FileOutputStream out=new FileOutputStream(“file.txt”, true);
D. FileOutputStream out=new FileOutputStream(new file(“file.txt”));
E. OutputStream out=new FileOutputStream(new File(“file.txt”)true);


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题Which two create an InputStream and open file the “file.txt” for reading? ()

A. InputStream in=new FileReader(“file.txt”);
B. InputStream in=new FileInputStream(“file.txt”);
C. InputStream in=new InputStreamFileReader (“file.txt”, “read”);
D. FileInputStream in=new FileReader(new File(“file.txt”));
E. FileInputStream in=new FileInputStream(new File(“file.txt”));

2.单项选择题Which determines if “prefs” is a directory and exists on the file system?()  

A. Boolean exists=Directory.exists (“prefs”);
B. Boolean exists=(new File(“prefs”)).isDir();
C. Boolean exists=(new Directory(“prefs”)).exists();
D. Boolean exists=(new File(“prefs”)).isDirectory();
E. Boolean exists=true;  Try{  Directory d = new Directory(“prefs”);  } catch (FileNotFoundException e) {  exists = false;  }

4.多项选择题Which two statements are true regarding the creation of a default constructor? ()  

A. The default constructor initializes method variables.
B. The compiler always creates a default constructor for every class.
C. The default constructor invokes the no-parameter constructor of the superclass.
D. The default constructor initializes the instance variables declared in the class.
E. When a class has only constructors with parameters, the compiler does not create a default  constructor.

5.单项选择题

 public class ArrayTest {  
public static void main (Stringargs) { 
 float f1, f2;  
f1 = new float [10]; 
f2 = f1;  
System.out.printIn (“f2[0]=” + f2[0]);  
} 
}  
What is the result?()

A. It prints f2[0] = 0.0
B. It prints f2[0] = NaN
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an exception at runtime.

8.单项选择题

public class Mycircle {  
public double radius;  
public double diameter;  
public void setRadius(double radius)  
this.radius = radius;  
this.diameter= radius * 2;  
}  
public double getRadius() { 
return radius;  
}  
Which statement is true?()  

A. The Mycircle class is fully encapsulated.
B. The diameter of a given MyCircle is guaranteed to be twice its radius.
C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation.
D. The radius of a MyCircle object can be set without affecting its diameter.

9.多项选择题Which two statements are true?()

A. An inner class may be declared as static.
B. An anonymous inner class can be declared as public.
C. An anonymous inner class can be declared as private.
D. An anonymous inner class can extend an abstract class.
E. An anonymous inner class can be declared as protected.