Programming Interview Questions

Answer is (b) 5. This is because static variables are related to class and not instance. Hence, the instance value doesn't hold good if a static variable is tried to be accessed.
Answer is c. trim() function is only performed if blankspaces are present at the beginning or end. If not present it will return the same string. Hence the function will return true. But if the string contains blankspaces, subString() is called to trim the string and return a new String using 'new' operator.