Questions from Starting Out With Java


Q: What is the output of the following code? int[]

What is the output of the following code? int[] values = new int[5]; for (int count = 0; count < 5; count++) values[count] = count + 1; for (int count = 0; count < 5; count++) System.out.println(value...

See Answer

Q: Show how the double variables temp, weight, and age can

Show how the double variables temp, weight, and age can be declared in one statement.

See Answer

Q: Write an input validation loop that asks the user to enter a

Write an input validation loop that asks the user to enter a number in the range of 1 through 4.

See Answer

Q: Write a statement that creates and initializes a double array with the

Write a statement that creates and initializes a double array with the following ­values: 1.7, 6.4, 8.9, 3.1, and 9.2. How many elements are in the array?

See Answer

Q: Look at the following statements: int[] numbers1 = {

Look at the following statements: int[] numbers1 = { 1, 3, 6, 9 }; int[] numbers2 = { 2, 4, 6, 8 }; int result; Write a statement that multiplies element 0 of the numbers1 array by element 3 of the nu...

See Answer

Q: What is the difference between an instance field and a static field

What is the difference between an instance field and a static field?

See Answer

Q: What action is possible with a static method that isn’t

What action is possible with a static method that isn’t possible with an instance method?

See Answer

Q: Describe the limitation of static methods.

Describe the limitation of static methods.

See Answer

Q: Look at the following code. Stock stock1 = new Stock

Look at the following code. Stock stock1 = new Stock("XYZ", 9.65); Stock stock2 = new Stock("SUNW", 7.92); While the equals method is executing as a result of the following statement, what object does...

See Answer

Q: Look at the following statement, which declares an enumerated data type

Look at the following statement, which declares an enumerated data type: enum Flower { ROSE, DAISY, PETUNIA } 1. What is the name of the data type? 2. What is the ordinal value for the enum constant R...

See Answer