0% found this document useful (0 votes)
56 views4 pages

What Is A Primitive What Is An Object - Pps

A primitive variable like int x stores its value directly in memory and is not an object. A String variable y is a reference to a String object; initially y is null until the new keyword is used to create a String object in memory, and y is made to reference the new object, pointing to its location.

Uploaded by

Marin_1wq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

What Is A Primitive What Is An Object - Pps

A primitive variable like int x stores its value directly in memory and is not an object. A String variable y is a reference to a String object; initially y is null until the new keyword is used to create a String object in memory, and y is made to reference the new object, pointing to its location.

Uploaded by

Marin_1wq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPS, PDF, TXT or read online on Scribd
You are on page 1/ 4

What is an Object?

What is a primitive?
What is an Object? What is a primitive?
int x; A primitive variable is NOT an object. It is stored in one
x = 2; place in RAM.

int x
2
What is an Object? What is a primitive?
String y;
A String is an object. Here, I have only declared a
reference. We say “’y’ is a reference to an object of
type String. However, at this point, ‘y’ points to
nothing.

String y
null
Now, using the new keyword to execute
What is an Object? What is a primitive?
the Constructor method, I have created
String y; an instance of the String class. Then, I
return the address (of the object I just
y = new String( “Hello” ); created) to the reference ‘y’, which then
points to the object. Now, ‘y’ points to the
object I just created.

String y
3433245

3433245

String “Hello”

You might also like