How do you declare an object reference variable?

1 answer

Answer

1008683

2026-07-17 10:51

+ Follow

For an object named Point you would declare an object reference variable like this:

Point p1;

The name p1 can be any valid variable name that you want. Note that p1 does not yet refer to an actual object yet, you have just created a reference to one (kind of like a pointer in C). To set p1 to actually refer to an instance of the object Point you could do something like this:

p1 = new Point();

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.