Questions from Starting Out With Java


Q: Under what circumstances does Java automatically provide a default constructor for a

Under what circumstances does Java automatically provide a default constructor for a class?

See Answer

Q: What is the difference between a size declarator and a subscript?

What is the difference between a size declarator and a subscript?

See Answer

Q: Look at the following array definition: int[] values =

Look at the following array definition: int[] values = { 4, 7, 6, 8, 2 }; What does each of the following code segments display? System.out.println(values[4]); x = values[2] + values[3]; System.out.pr...

See Answer

Q: Assuming that array1 and array2 are both array reference variables, why

Assuming that array1 and array2 are both array reference variables, why is it not possible to assign the contents of the array referenced by array2 to the array referenced by array1 with the following...

See Answer

Q: The following statement creates a BankAccount array: BankAccount[ ]

The following statement creates a BankAccount array: BankAccount[ ] acc = new BankAccount[10]; Is it okay or not okay to execute the following statements? acc[0].setBalance(5000.0); acc[0].withdraw(10...

See Answer

Q: Describe one thing you cannot do with a static method.

Describe one thing you cannot do with a static method.

See Answer

Q: Under what circumstances does an object become a candidate for garbage collection

Under what circumstances does an object become a candidate for garbage collection?

See Answer

Q: Describe the difference in the way variables and class objects are passed

Describe the difference in the way variables and class objects are passed as arguments to a method.

See Answer

Q: A “has a†relationship can exist between classes.

A “has a†relationship can exist between classes. What does this mean?

See Answer

Q: The variable myWindow references a JFrame object. Write a statement that

The variable myWindow references a JFrame object. Write a statement that sets the size of the object to 500 pixels wide and 250 pixels high.

See Answer