1 Consider the effects of String interning and String immuta
1 Consider the effects of String interning and String immutability. After the following code is executed, which of the following statements is/are true?
String s1 = \"Bigfoot\";
 String s2 = \"Bigfoot\";
 String s3 = new String(\"Bigfoot\");
 String s4 = s3;
s1 and s4 refer to the same object in memory
 s1 and s2 refer to the same object in memory
 s1 and s3 refer to the same object in memory
 s3 and s4 refer to the same object in memory
 s1.equals(s4) evaluates to true
2 Consider this code, which represents all the code provided for the class:
public class Student {
    private String name;
   public void setName(String name){
         this.name = name;      
    }
 }
Is it possible to create an instance of this class using a constructor?
No, because no constructor is provided in the code
 Yes, because it will have an implicit constructor
 Yes, because the class that needs to create a Student has its own constructor
 No, because there are no static methods
 Yes, because setName() is a constructor
3 Consider this code:
public class Clown extends Monster {
    private String name;
   public Clown(String nameIn){
         name = nameIn;      
    }
 }
What does the method Clown return?
A reference to a String
 A copy of a String
 A copy of a Clown
 Nothing
 A reference to a Clown
4 Which of the following is correct?
getters are also called accessors
 setters are also called accessors
 getters are also called mutators
 constructors are also called mutators
 accessors are usually static
5 Consider this method:
public void showName(){
System.out.println(name);
}
Which of the following is correct?
This method is a constructor
 This method is a setter
 This method is a mutator
 This method is static
 None of the above
Solution
1)s1 and s2refers to the same object in memory is true and also s1.equals(s4) returns true
2)yes ,because it will have an implicit constructor
3)Clown returns a reference to Clown
4) getters are also called accessors
5)None of the above


