Share
Explore BrainMass

Java Class and Attribute Mixed Questions

1. Is there ever a reason to have a public attribute in a class?

2. What does it mean for a method to be overloaded?

3. Is it true or false that every class should have a toString( ) method that returns a String which is a text representation of the object. The method is not sent any actual. Is the toString( ) method overridden?

4.What is the value of s2:

String s1 = new String( "2 late 2 drop" );
String s2 = s1.substring( 3, 6 );

5. Is it true or false that the toUpperCase( ) method of the String class is a mutator?

6. When should an attribute of a class be static?

7. Is it true or false that if a method within a class is static, then the method can be called without an instance of the class?

8. What two access specifier keywords can be used to encapsulate attributes and behaviors within a class?

9. Is it true or false that inheritance creates an "is-a" relationship between classes?

Solution Preview

1. Is there ever a reason to have a public attribute in a class?

answer: when a class has a constant attribute that can be accessed by anyone, then
you could make the constant attribute public.

2. What does it mean for a method to be overloaded?

answer: it is a way to use the same method name with a different method signature which is determined
by the number of the method parameters, the types of the parameters and the order of the ...

Solution Summary

The solution briefly answered 9 simple questions about basic Java use, touching on strings, protected vs. private and more.

$2.19