This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Object Reference Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Object Reference Question" Watch "Object Reference Question" New topic

Object Reference Question

paul pavlentey

Joined: Jul 20, 2006
Posts: 10
I have very basic Java Question about object assignment.
public interface Animatable {
public void animate();
public class GameShape {
public void displayShape() {
System.out.println("Displaying Shape");

class which extends GameShape and implements interface Animatable
public class PlayerPiece extends GameShape implements Animatable{
public void movePiece() {
System.out.println("moving game piece");
public void animate() {


I dont understand the following assignement of variable "player".
I understand new object player is created (
PlayerPiece player= new PlayerPiece() ,
but how player is assigned to Object, GameShape and Animatable.
Object o=player;
GameShape shape=player;
Animatable mover=player;

What will it to player and how instances of Object, GameShape and Anumatable are effected?

Thanks in advance,
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Welcome to the Sun Certified Java Programmer Certification forum at JavaRanch.
I'm moving your question to our Java In General (Beginner) forum...

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: Object Reference Question
It's not a secret anymore!