Questions from Starting Out With Java


Q: Assume that the following enumerated data type has been declared:

Assume that the following enumerated data type has been declared: enum Creatures{ HOBBIT, ELF, DRAGON } What will the following code display? System.out.println(Creatures.HOBBIT + " " + Creatures.ELF...

See Answer

Q: Assume that the following enumerated data type has been declared:

Assume that the following enumerated data type has been declared: enum Letters { Z, Y, X } What will the following code display? if (Letters.Z.compareTo(Letters.X) > 0) System.out.println("Z is greate...

See Answer

Q: Write a statement that converts the contents of the char variable big

Write a statement that converts the contents of the char variable big to lowercase. The converted value should be assigned to the variable little.

See Answer

Q: Write nested loops to draw this pattern: /

Write nested loops to draw this pattern:

See Answer

Q: What is the difference between the indexOf and lastIndexOf methods?

What is the difference between the indexOf and lastIndexOf methods?

See Answer

Q: What is the difference between the getChars and substring methods?

What is the difference between the getChars and substring methods?

See Answer

Q: The + operator, when used with strings, performs the same

The + operator, when used with strings, performs the same operation as what String method?

See Answer

Q: What is the difference between the getChars and toCharArray methods?

What is the difference between the getChars and toCharArray methods?

See Answer

Q: Look at the following code: String str1 = "To

Look at the following code: String str1 = "To be, or not to be"; String str2 = str1.replace('o', 'u'); System.out.println(str1); System.out.println(str2); You hear a fellow student claim that the code...

See Answer

Q: What will the following code display? String str1 = "

What will the following code display? String str1 = "William "; String str2 = " the "; String str3 = " Conqueror"; System.out.println(str1.trim() + str2.trim() + str3.trim());

See Answer