Which correctly creates an array of five empty strings

Assignment Help JAVA Programming
Reference no: EM131085491

Question 1. Which of the following statements is false?

You can create a FileInputStream/FileOutputStream from a File object or a file name using FileInputStream/FileOutputStream constructors.
A java.io.FileNotFoundException would occur if you attempt to create a FileOutputStream with a nonexistent file.
All methods in FileInputStream/FileOutputStream are inherited from InputStream/OutputStream.
The return value -1 from the read() method signifies the end of file.
A java.io.FileNotFoundException would occur if you attempt to create a FileInputStream with a nonexistent file.

Question 2. Given a graphics object g, to draw a filled arc with radius 20 centered at (50, 50) and start angle 0 and spanning angle 90, you use _____

g.fillArc(50, 50, 20, 20, 0, 90).
g.fillArc(50, 50, 40, 40, 0, 90).
g.fillArc(30, 30, 40, 40, 0, Math.toRadian(90)).
g.fillArc(30, 30, 40, 40, 0, 90).
g.fillArc(50, 50, 40, 40, 0, Math.toRadian(90)).

Question 3. Which of the following statements is false?

Invoking repaint() causes paintComponent to be invoked by the JVM.
The paintComponent method is automatically invoked by the JVM. You should never invoke it directly.
Whenever a GUI component is displayed, its graphics object is automatically created.
You may create a graphics object using new Graphics().

Question 4. After the following program is finished, how many bytes are written to the file t.dat?

import java.io.*;
public class Test {
public static void main(String[ ] args) throws IOException {
DataOutputStream output = new DataOutputStream(
new FileOutputStream("t.dat"));
output.writeChar('A');
output.close();
}
}

8 bytes
2 bytes
4 bytes
none of the above

Question 5. Which of the following is the legal mode for creating a new RandomAccessFile stream?

"rw"
"rwx"
"w"
'r'

Question 6. Suppose you enter 34.3 57.8 789, then press the ENTER key. Analyze the following code.

Scanner scanner = new Scanner(System.in);
int intValue = scanner.nextInt();
int doubleValue = scanner.nextInt();
String line = scanner.nextLine();
After the last statement is executed, line contains characters '7', '8', '9'.
After the last statement is executed, line contains characters '7', '8', '9', '\n'.
After the last statement is executed, intValue is 34.
The program has a runtime error because 34.3 is not an integer.

Question 7. Assume s is "ABCABC", the method _____ returns a new string "aBCaBC."

s.toLowerCase(s)
s.toLowerCase()
s.replace("ABCABC", "aBCaBC")
s.replace('a', 'A')
s.replace('A', 'a')

Question 8. Which correctly creates an array of five empty Strings?

String[ ] a = new String [5]; for (int i = 0; i < 5; a[i++] = null);
String[ ] a = new String [5];
String[5] a;
String[ ] a = {"", "", "", "", ""};

Question 9. Which of the following statements is preferred to create a string "Welcome to Java"?

String s; s = "Welcome to Java";
String s = "Welcome to Java";
String s = new String("Welcome to Java");
String s; s = new String("Welcome to Java");

Question 10. Suppose s is a string with the value java. What will be assigned to x if you execute the following code?

char x = s.charAt(4);
'v'
'a'
Nothing will be assigned to x, because the execution causes the runtime error StringIndexOutofBoundsException.

Reference no: EM131085491

Questions Cloud

Who recognize the best time to avoid problems : The concept that the quality of the output is only as good as the quality of the input, which sometimes is known as __________, is familiar to IT professionals, who recognize that the best time to avoid problems is when data is entered.
Charge builds up on each plate of the capacitor : a. What happens to the voltage measured across the resistor when a 12V battery is added in series in the circuit? b. What total charge builds up on each plate of the capacitor?
Why is human resources important : Physical resources is important because the business needs to ensure the equipment are correctly fitted and products are highly standard so that the business increase sales.
Determine the specific heat capacity : Assuming all the heat lost by the water is gained by the metal and that the cup is perfectly insulated, determine the specific heat capacity of the unknown metal. The specific heat capacity of water is 4.18 J/g/°C.
Which correctly creates an array of five empty strings : Which correctly creates an array of five empty Strings? Which of the following statements is preferred to create a string "Welcome to Java"?
Calculate the number of pascals : A certain truck is moving in an eastern direction and its load is 400N.The area that the vehicle is passing is an equivalent of a square 5m sided in the western direction. Using the knowledge learn t in physics calculate the number of pascals.
Develop blog discussing importance of tailoring recruitment : Develop a blog discussing the importance of tailoring recruitment strategies to the target candidate pool. Provide clear, specific examples to support your points.
Find the induced emf : Figure in textbook (fig. P31.14) the current in the solenoid changes as I = 5.00sin 120t, where I is in amperes and t is in seconds. Find the induced emf in the 15-turn coil as a function of time.
Formulate the network security plan to be implemented : Review the work you have done and formulate the Network Security Plan to be implemented across the network footprint. What is being done to secure the network at different levels of the OSI model and the organizational structure.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Application for an animal-fur trimming service

Create an application for an animal-fur trimming service. Write the code for the application. Prompt the user to indicate how many animals. Display the total fee for one year. Be pleasant in your output as it will be expensive.

  Define multiple classes via inheritance

Your task for this assignment is to define multiple classes via inheritance. Your classes should implement various "snacks" including "M&Ms", "Popcorn", etc.

  Shows the users name and program name

Java program, the program has a page that shows the users name and program name. a second jpanel that shows 4 buttons (circle square rectangle and oval) the problem i am having is that my program is not dropping where i click and the shapes are not s..

  Advantage of a multilevel page table over

Suppose that a machine has 38-bit virtual addresses and 32-bit physical addresses. (a) What is the main advantage of a multilevel page table over a single-level one?

  Java program that computes a ride you took in taxi

Write a java program that computes a ride you took in taxi. The bill computed based on an initial cost plus the taxi charges 0.5 dirham every 0.3 km.

  The burn and distance traveled

The Burn and distance traveled and the "meters to go" should appear on two lines as shown in the sample output. Note that this print should be done within the while loop.

  What makes a program easy to modify

Describe the order of magnitude of the code section using Big(O) notation and Explain the relationship between dynamic storage allocation and recursion.

  Program that inputs a word representing a binary number

Write a program that inputs a word representing a binary number (0s and 1s). First your program should verify that it is indeed a binary number, that is the number contains only 0s and 1s.

  Number for all nonnegative values

Please if you could show the work for each problem and also if you could advise the theorem used to solved the problem. Does n2 + n +11 always represent a prime number for all nonnegative values of n?

  Implement function boolean containsconsecutiveleftrededges

Implement the following functions- void insert(), boolean containsRightRedEdge(), boolean containsConsecutiveLeftRedEdges(), int countBlackEdgesOnLeftmostPath() and boolean sameBlackEdgesCountOnAllPaths(int count).

  Setting up the form page

Download and save the attached comment CGI mailer script form-mail2.pl to your server's cgi-bin directory, and change the permissions on the script to make it executable (not writable).

  Create a hang man type program

Create a hang man type program - create the full final picture image, and then rub out a piece and save it as a different filename, then rub out another part and save it as a different name.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd