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

  Write an application class that contains several methods

Write a driver class. This class should use the main method to call four methods in the application class that will display our JOptionPanes - Write an application class that contains several methods.

  Code 2-dimensional array that stores the average scores

Instructions: Code a 2-dimensional (2D) array that stores the average scores for 2 football teams across 2 years. In a method called setAvgScores, prompt for the averages and store them in the 2D array which will be returned

  Conduct an internet search for javadb tutorial you might

please write a 200-400 word response to the following questionq1. conduct an internet search for javadb tutorial. you

  Powerful pain reliever are consumers with headaches

Your target market for the most powerful pain reliever are consumers with HEADACHES. Start with goals and objectives. Do a SWOT. What information is most important for your market? Do some market research.

  The ai player will not be asking

The AI player will not be asking the user for any input. This means that placeShips() and fire() should not ask the user for locations. The AI player should choose locations of ships and automatically place them

  Write code that prompts the user to enter a string

Write code that prompts the user to enter a string containing ONLY a series of digits, then complete all of the following operations:

  Write a java program that uses the elapsed time

Write a Java program that uses the elapsed time for an event in second and then outputs the elapsed time in hours, minutes and seconds. (For case, if the desired time is 9630 seconds, then the output is 2: 40: 30)

  Java program that will add the corresponding elements

Develop a Java program that will add the corresponding elements of two 1-dimensional arrays X and Y to produce the 1-dimensional array Z. Arrays X, Y, Z have the same dimension [M].

  What is method overloading

1. What is method overloading? 2. What is the purpose of a constructor? 3. How do you call a method of one class from a method of another class?

  Implementation of tru file system

Design and implement TFS. It is a file system that can be used on a standalone machine. There are several simplifying assumptions such as a single application is accessing the file system at any given time.

  Frequently used java array method

Frequently used java array method -method name and parameter

  Write a simple gui program that allows users to type

Write a simple GUI program that allows users to type in any long message and to display the number words when the button "Count Words" is pressed.

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