I
Size: a a a
I
I
I
I
SS
SS
SS
I
I
JC
class Formatter {
void print(Showable o) {
System.out.println("Object = " + o.toString())
}
}
abstract class Showable {
String toString();
}
class A extend Showable {
String toString() {
retun "A"
}
}
class B extend Showable {
String toString() {
return "B"
}
}
class Main() {
void main() {
a = new A();
b = new B();
Formatter.print(a); //ok because A inherit from Showable
Formatter.print(b); //ok because B also inherit from Showable
}
}
I
class Formatter {
void print(Showable o) {
System.out.println("Object = " + o.toString())
}
}
abstract class Showable {
String toString();
}
class A extend Showable {
String toString() {
retun "A"
}
}
class B extend Showable {
String toString() {
return "B"
}
}
class Main() {
void main() {
a = new A();
b = new B();
Formatter.print(a); //ok because A inherit from Showable
Formatter.print(b); //ok because B also inherit from Showable
}
}
I
I
SS
class Formatter {
void print(Showable o) {
System.out.println("Object = " + o.toString())
}
}
abstract class Showable {
String toString();
}
class A extend Showable {
String toString() {
retun "A"
}
}
class B extend Showable {
String toString() {
return "B"
}
}
class Main() {
void main() {
a = new A();
b = new B();
Formatter.print(a); //ok because A inherit from Showable
Formatter.print(b); //ok because B also inherit from Showable
}
}
SS
SS
JC
class Formatter {
void print(Showable o) {
System.out.println("Object = " + o.toString())
}
}
abstract class Showable {
String toString();
}
class A extend Showable {
String toString() {
retun "A"
}
}
class B extend Showable {
String toString() {
return "B"
}
}
class Main() {
void main() {
a = new A();
b = new B();
Formatter.print(a); //ok because A inherit from Showable
Formatter.print(b); //ok because B also inherit from Showable
}
}
SS
SS