<< Chapter < Page | Chapter >> Page > |
Revised: Tue Mar 29 11:29:05 CDT 2016
This page is included in the following Books:
This module contains review questions and answers keyed to the module titled Jb0280: Java OOP: String and StringBuffer .
The questions and the answers are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again.
Java provides two different string classes from which string objects can be instantiated. What are they?
True or false? The StringBuffer class is used for strings that are not allowed to change. The String class is used for strings that are modified by the program. If false, explain why.
True or false? While the contents of a String object cannot be modified, a reference to a String object can be caused to point to a different String object. If false, explain why.
True or false? The use of the new operator is required for instantiation of objects of type String . If false, explain your answer.
True or false? The use of the new operator is required for instantiation of objects of type StringBuffer . If false, explain your answer
Provide a code fragment that illustrates how to instantiate an empty StringBuffer object of a default length and then use a version of the append method to put some data into the object.
Without specifying any explicit numeric values, provide a code fragment that will instantiate an empty StringBuffer object of the correct initial length to contain the string "StringBuffer named str6" and then store that string in the object.
Provide a code fragment consisting of a single statement showing how to use the Integer wrapper class to convert a string containing digits to an integer and store it in a variable of type int .
Explain the difference between the capacity method and the length method of the StringBuffer class.
True or false? The following is a valid code fragment. If false, explain why.
StringBuffer str6 =
new StringBuffer("StringBuffer named str6".length());
Which of the following code fragments is the most efficient, first or second?
String str1 = "THIS STRING IS NAMED str1";
String str1 = new String("THIS STRING IS NAMED str1");
Write a Java application that illustrates the fact that while a String object cannot be modified, the reference variable can bemodified to point to a new String object, which can have the appearance of modifying the original String object.
Write a Java application that illustrates different ways to create String objects and StringBuffer objects.
Write a Java application that illustrates conversion from string to numeric.
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?