1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
almond37 [142]
3 years ago
5

Public class Question4

Computers and Technology
1 answer:
enyata [817]3 years ago
4 0

Answer:

See explaination

Explanation:

import java.io.File;

import java.io.PrintWriter;

public class Question4 {

/*

* For this exercise you will be doing some basic operations to write to a

* file. You will be creating your very own Secrets of the Universe (TM)

*

* You can use the PrintWriter class to write to files (Chapter 11.4)

*

* Your code should perform the following actions:

*

* 1) Open/Create a file for writing at the following location:

* "files/question4/MySecretsOfTheUniverse.txt" If the file already exists

* you will want to overwrite its contents. 2) Add at least 3 of your own

* secrets of the universe to the file. Each secret should be on its own

* line. 3) Make sure to close your file so that the results are saved.

*

* Note: Your code should not throw any checked exceptions.Note: You will

* need to import some classes from the java.io package.

*/

public static void Question4() {

// creating a File object

File file = new File("files/question4/MySecretsOfTheUniverse.txt");

try {

// opening print writer to write to the file. the file will be

// created if not exist, but you have to ensure that the directory

// files/question4/ exists.

PrintWriter writer = new PrintWriter(file);

// writing three random statements to the file. I dont know anything

// about the secrets of universe you mentioned, so I'm just writing

// some random stuff that came into my mind. You can replace below

// lines with whatever you want to write.

writer.println("Humans are aliens from Mars, sent here to colonize Earth after they screwed up mars.");

writer.println("This universe and everything in it are probably brain cells of some huge cosmic organism.");

writer.println("There may be other forms of life co-exist here on our Earth that we can't see,"

+ " because they vibrate at a different frequency outside of all our measurements");

//closing file, saving changes

writer.close();

} catch (Exception e) {

//printing error if exception is occurred.

System.err.println(e);

}

}

public static void main(String[] args) {

Question4();

}

}

You might be interested in
Jenn wants to assign a value to the favorite car variable: favoriteCar = Toyota but gets an error message. What does she need to
Bumek [7]

Answer:

The correct answer is: Option d: Put Quotation marks around the string.

Explanation:

The names of things or places or cars are usually in the form of words or sentences. The words or sentences are stored in string datatype.

Quotation marks are used to deal with strings in programming languages.

Hence,

The correct answer is: Option d: Put Quotation marks around the string.

3 0
3 years ago
What group actively creates technology recommendation for the web?
xxMikexx [17]

The NETP provides actionable recommendations to implement technology and conduct research and development successfully that can advance the effective use of technology to support learning and teaching.


Hope this helps :)



6 0
3 years ago
Read 2 more answers
What is an example of technology that helps support the idea of continental drift.
docker41 [41]

I don't know technology, but using Satellite images, we are able to see that the continents once fitted into one 'jigsaw'. This shows that the continents must have drifted to its original place. Furthermore, Geothermal stations have pointed out convection currents in the Earth's mantle has caused the movement of crusts.
8 0
3 years ago
The area that holds all the startup instructions the computer needs to start is the
Zigmanuir [339]
The area that holds all the startup instructions the computer needs to start is the ROM, or read-only memory. 
8 0
3 years ago
To annotate a document with a remark for another reviewer to address, select the _____ feature. comments track changes annotatio
kupik [55]
Select the comments feature.

We use comments in our documents to track issues for follow up or make suggestions to other people. A comment is inserted inside a balloon or a box that appears in the document's margins. Whatever the situation you may be in, you can easily add comments in a word document.

 



6 0
3 years ago
Read 2 more answers
Other questions:
  • Which device on a network performs network address translation?
    8·1 answer
  • If a user has just added a simple triangle shape into a diagram, how can the triangle be adjusted? Check all that apply. by maki
    6·2 answers
  • When a computer is booted the checks the computer's components?
    7·1 answer
  • What kind of information B2B SaaS companies wish to know about their competition, apart from information about their competitors
    15·1 answer
  • Are one of the greatest features of Photoshop that allow nondestructive editing of images.
    6·1 answer
  • Do you think I could create a working animatronic like the one from five nights at freddys
    12·2 answers
  • What symbol do we use to denote a character?
    14·1 answer
  • Add my sna-p dkarpik58?...
    9·1 answer
  • What are the difference among the whole note, half note and quarter note ? (this is music)
    12·2 answers
  • How have productivity programs improved the professional lives of people? (check all that apply)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!