Given the following declaration of a field in a class: public static final String GREETING = "Hi";
Which of these statements is not true?

a) Each object of this class can access GREETING
b) The value of greeting can’t be changed in any methods
c) Each object of this class has its own copy of GREETING
d) GREETING.length() = 2
e) GREETING.toUpperCase() = "HI"

Respuesta :

Debel

Answer:

Each object of this class has its own copy of GREETING

Explanation:

option c: Each object of this class has it’s own copy of GREETING

This is the only false statement.  When a variable is preceded by the Static key word only one copy of that variable is created, no matter the amount of object created from the instance of that class.

option a: Each object of this class can access GREETING, this is true.

option b: The value of GREETING can’t be changed in any methods, this is true because GREETING is preceded by the keyword final.

option d: GREETING.length() = 2, this is true because the method length() is use to get the length of the string "Hi" which is 2.

option e: GREETING.toUpperCase() = "HI", this is also true because the method toUpperCase()  convert all the character of "Hi" to uppercase.

Note: All these are peculiar to java programming language.