Home > Back-end >  The problem of instanceof which bosses know ah beg for help
The problem of instanceof which bosses know ah beg for help

Time:10-09

The class Birds
{
Public void the work ()
{
System. The out. Println (" President main work ");
}
}
The class Chickens extends Birds
{
Public void the work ()
{
System. The out. Println (" Chickens main work ");
}
}
The class Main
{
Public static void main (String [] args)
{
Birds s=new Chickens ();
S. ork ();
Birds z=new Birds ();
Z.w ork ();
Birds q=new Birds ();
If (q instanceof Chickens)//no error is normal?
{
Chickens p=(Chickens) q;
}

}
}

CodePudding user response:

Q instanceof Chickens this return false

CodePudding user response:

run no hint is run directly after success can increase some hints?? where
  • Related