Answer:
BufferedWriter salesdata = new BufferedWriter(new FileWriter("out.dat", true);.
Explanation:
- The statement BufferedWriter salesdata = new BufferedWriter(new FileWriter("out.dat", true); can be used to create a file object that will append data to an existing file.
- Here, BufferedWriter class is used to create text from an output stream.
- Here, FileWriter is used to create the file from the text. The constructor for FileWriter is FileWriter (String filename, boolean append).
- Here, filename is string ("out.dat") is provided and the append is boolean can be either true (if the text has to be appended at the end of the file) or false (if the text hasn't to be appended at the end of the file).
- So, option (b) is correct.
- Option (a) is not correct as it indicates the text shouldn't be appended at the end of the file as the boolean is false.
- Option (c) is not correct as it doesn't mean to append as there is no boolean true indicated in the constructor.
- Option (d) is not correct as there is not such kind of syntax.
Answer:
Almost 80 percent of websites are mobile friendly
Explanation:
Answer:
The answer to this question is the option "a".
The statement for opening file can be given as:
inFile.open("progdata.dat");
Explanation:
In the above statement, this statement is part of the c++ programming language. To open any file we use the following syntax that can be given as:
Syntax:
inFile.open(filename, mode);
In the above syntax inFile.open() is a function that opens the file. In this function, we pass two parameters that are filename, mode. Where filename is the name of the file which we want to open. In the filename, we write file names with the path of the file like(C:\Users\Public\Music\Sample Music\abc.dat) where (C:\Users\Public\Music\Sample Music) is the path of the file and (abc.dat) is a file name. In the mode parameter, it provides the mode in which we want to open a file. There are two types of read mode and write mode. The default mode is read mode.
Answer:
Explanation:
public class Main
{
public static void main(String[] args) {
System.out.println("Test Class:");
Name name = new Name("Dayanand","Ghelaro");
System.out.println("First Name : "+name.getFirstName());
System.out.println("Last Name : "+name.getLastName());
}
}
class Name{
private String firstName; // first name field
private String lastName; // last name field
public Name(String firstName, String lastName){
this.firstName = firstName;
this.lastName = lastName;
}// end of constructor
public String getFirstName(){
return this.firstName;
} // end of method
public String getLastName(){
return this.lastName;
}// end of method
}// end of Name class