Question: public class player { private String s1; protected Object shape; player(){ } public Object getShape() { return shape; } // not good practise to allow

public class player {

private String s1;

protected Object shape;

player(){

}

public Object getShape() {

return shape;

}

// not good practise to allow other client classes

// to change the player's character

// a good practise is to protect this method as private

// only itself can change the player character

private void setShape(Object shape) {

this.shape = shape;

}

// intialize a player with a character representing it

public player(Object playerchar) {

super();

this.shape = playerchar;

}

}

public class HumanPlayer extends player {

HumanPlayer(){

super();

}

HumanPlayer(Object shape){

//super();

this.shape = shape;

}

@Override

public void play(TicTacToeBoard ttcb) {

super.play(ttcb);

}

}

Question 1: Did HumanPlayer inherit all of players attributes and methods, including constructors? What are the access modifiers for the inherited methods and attributes?

Question 2: HumanPlayer ahp = new HumanPlayer(); ahp.play(); which method is called?

Question 3: How does HumanPlayer call players constructor?

Question about polymorphism

Polymorphism - Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

Which one is polymorphism, and which one is not?

class Window {

public void open() {

}

}

class ScrollableWindow extends Window {

@Override

public void open(){

}

}

class DialogWindow extends Window {

@Override

public void open(){

}

}

Question: which open functions were called?

Window sw = new ScrollableWindow();

sw.open();

Window dw = new DialogWindow();

dw.open();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!