package class_oop_polymorphism;
class TV
{
boolean power;
int channel;
void SetPower()
{
power=!power;
}
void SetChannelUp()
{
if(power==true)
{
++channel;
System.out.println("Now, Channel Up");
}
else
{
return;
}
}
void SetChannelDown()
{
if(power==true)
{
--channel;
System.out.println("Now, Channel Down");
}
else
{
return;
}
}
}
public class CaptionTV extends TV{
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
We can do like this!↓
public class CaptionTV extends TV{
public static void main(String[] args) {
// TODO Auto-generated method stub
CaptionTV c=new CaptionTV();
TV t=new CaptionTV();//polymorphism
}
}
So, can assign Child class instance to Parent Class instance