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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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