163k views
2 votes
Examine the following declarations:

int area;
String name;
Which of the following is true?
A. area is a primitive variable, and the name is a reference variable.
B. area is a reference variable, and the name is a primitive variable.
C. both are primitive variables
D. both are reference variables

1 Answer

4 votes

Final answer:

The correct answer is A, where 'area' is a primitive variable and 'name' is a reference variable. 'int' stores numerical values directly, while 'String' is a class and references an object containing a sequence of characters.

Step-by-step explanation:

Among the given declarations:

  • int area;
  • String name;

The statement that is true is:
A. area is a primitive variable, and the name is a reference variable.

In Java, int is one of the eight primitive data types which means it stores the actual numerical value assigned to the variable. The String data type, on the other hand, is a class and therefore name is a reference to an object that stores the sequence of characters.

User Michael Dougan
by
7.7k points