100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COSC Exam Questions with All Correct Answers $13.49   Add to cart

Exam (elaborations)

COSC Exam Questions with All Correct Answers

 11 views  0 purchase
  • Course
  • COSC
  • Institution
  • COSC

COSC Exam Questions with All Correct Answers What will be the value of x after the following code is executed? int x =10; while(x < 100); { x += 10; } - Answer-This is an infinite loop What package needs to be imported in order to create a file for java to write to? - Answer-import *;...

[Show more]

Preview 2 out of 7  pages

  • August 28, 2024
  • 7
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • COSC
  • COSC
avatar-seller
Scholarsstudyguide
COSC Exam Questions with All
Correct Answers
What will be the value of x after the following code is executed?
int x =10;
while(x < 100);
{
x += 10;
} - Answer-This is an infinite loop

What package needs to be imported in order to create a file for java to write to? -
Answer-import java.io*;

What is the name of the class that is used to create an object for writing to a file? -
Answer-PrintWriter

What should be the data type if the file name? - Answer-String

What two programming words should be written after the main method
header(immediately to the right) to prevent an error in compiling code with file
manipulation? - Answer-throws IOException

Name the three output methods that may be used with the output file object to write
code to a file - Answer-outputFile.println("");
outputfile.print("");
outputfile.printf("");

What is the class that is used to create an object that will allow a programmer/user to
add data to a file rather than only just creating a file? - Answer-FileWriter

t/f The PrintWriter object erases an exiting file and rewrites it every time an execution is
run - Answer-true

t/f Along with the file name, you have to state the boolean value false when creating a
FileWriter object to allow content to be added to a file - Answer-false

t/f A PrintWriter object is necessary if a FileWriter object is being used to work with a file
- Answer-True

What is the class necessary to create an object that is used to read a file - Answer-File

, What common class is necessary to create an object that will read the content of a file
rather than input from the keyboard buffer - Answer-Scanner Scanner inputFile =
newScanner(file)

(Scanner, the Scanner class)

t/f You should include the file extension in your file names - Answer-true

A __ file is the preferable file type for storing files for processing with the file extension
__ - Answer-text, .txt

The __ () method is used to determine the existence of a file - Answer-.exists()

The __ () method reads a file until is runs into an end-of-file character - Answer-
.hasNext

This method is used to close both file reading and file writing objects to release memory
back to RAM - Answer-inputFile.close();

Write only the code that creates a file called "programming output.txt" that is ready to be
written to - Answer-PrintWriter.outputFile = new PrintWriter("programmingOut.put.txt");
outputFile.println("writing");


What will be the value of x after the following code is executed?
int x = 10;
while(x<100)
{
x +=10;
} - Answer-100

t/f In a for statement, the control variable can only be incremented. - Answer-false

t/f You can use the PrintWriter class to open a file for writing and write data to it. -
Answer-true

t/f Java provides a set of simple unary operators designed just for incrementing and
decrementing variables. - Answer-true

t/f The do-while loop is a pre-test loop. - Answer-false

t/f In the for loop, the control variable cannot be initialized to a constant value and tested
against a constant value. - Answer-false

How many times will the following do-while loop be executed?
int x = 11;
do

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Scholarsstudyguide. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

80461 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.49
  • (0)
  Add to cart