Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package class_online_8_8_15;
- abstract class AbstractTest
- {
- int num = 0 ;
- abstract void show();
- void defination()
- {
- System.out.println("Defination");
- }
- }
- public class A extends AbstractTest
- {
- A()
- {
- }
- @Override
- void show()
- {
- //statement
- }
- }
- abstract class Insect
- {
- public String name;
- public String colour;
- abstract void move();
- abstract void attack();
- public String toString()
- {
- return name+"\n"+colour;
- }
- }
- public class Fly extends Insect
- {
- Fly()
- {
- super();
- }
- String name = " Fly ";
- String colour = " black ";
- @Override
- void move()
- {
- System.out.println(" flying ");
- }
- @Override
- void attack()
- {
- System.out.println(" fly and suck ");
- }
- public String toString()
- {
- return name+" "+colour;
- }
- }
- public class Cockroach extends Insect
- {
- Cockroach()
- {
- super();
- }
- String name = " Cockroach ";
- String colour = " black and red ";
- @Override
- void move()
- {
- System.out.println(" walking ");
- }
- @Override
- void attack()
- {
- System.out.println(" run and bite ");
- }
- public String toString()
- {
- return name+"\n"+colour;
- }
- }
- public class Class_Online_8_8_15
- {
- public static void main(String[] args)
- {
- Fly f = new Fly();
- Cockroach c = new Cockroach();
- System.out.println(""+f.toString());
- f.move();
- f.attack();
- System.out.println(""+c.toString());
- c.move();
- c.attack();
- }
- }
Add Comment
Please, Sign In to add comment