This discussion is archived
3 Replies Latest reply: Dec 9, 2012 12:27 PM by EJP RSS

i need to verify my program. LOCKED FOR DELETION

978238 Newbie
Currently Being Moderated
frnds im new to java..my bro give me one homework...i did it.. bt i have still doubt. pls tell me the correction in my program..............

Create an interface Vechile with methods wheel return type int, create three classes with name bus,car and bike implementing Vechile. Create a method called TestVechile and create object of above three classes and call the method wheel and print the output.



code::

interface vechile{
     
     public int wheel();
     
     
     
}
/* public class bus implements vechile{
     
     public int wheel(int b)
     
     {
          int a=6;
          b=a;
          //if (b==7)
          System.out.println(a);
          
          return 0;
          //return a;
          
     }*/

          
// }
class bus implements vechile{
     
     public int wheel()
     {
          
          System.out.println("car");
          return 0;
     }
}
class bike implements vechile{
     
     public int wheel()
     {
          
          System.out.println("bike");
          return 0;
     }
}
class car implements vechile{
     
     public int wheel()
     {
          
          System.out.println("car");
          return 0;
     }
}

public class TestVechile {
     public static void main(String a1[])
     {
          bus b =new bus();
          car c = new car();
          bike d=new bike();
          b.wheel();
          
          c.wheel();
     d.wheel();
     
          
          
          
     }

}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points