tag:blogger.com,1999:blog-1235110526979374490.post4668866800904247854..comments2023-12-08T13:35:58.285+05:30Comments on WELCOME TO JAVA FAQS: WHAT IS ABSTRACT KEYWORD ?Unknownnoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-1235110526979374490.post-10090714705501446502011-01-24T17:27:19.091+05:302011-01-24T17:27:19.091+05:30in the above example v.wheels() will give me??
a c...in the above example v.wheels() will give me??<br />a car has four wheels is it correct?<br /><br />what if in the same example<br />abstract class vehicle{<br />abstract void wheels()<br />public void run()<br />{system.out.println("vehicle is at x speed")<br />}};<br />class car extends vehicle{<br />void wheels(){system.out.println("a car has four wheels")<br />public void run()<br />{system.out.println("car is at x speed")<br />};}<br />public static void main(String[] args){<br />vehicle v=new car();<br />v.run();<br />}<br />}<br />v.run() which class call???Abhijeethttps://www.blogger.com/profile/02251381924960168804noreply@blogger.comtag:blogger.com,1999:blog-1235110526979374490.post-64328749370236470382010-08-27T08:31:12.471+05:302010-08-27T08:31:12.471+05:30ya absolutely,
abstract class gives the method bod...ya absolutely,<br />abstract class gives the method body which is already known and no need to define the body by our self,<br />but it makes the methods abstract which body is not known, <br /><br />See the method is used somewhere else in the class or in another class, when you override the same method then the body is used,<br /><br />for EX suppose there is an abstract class having one abstract method display() and what ever you write inside this abstract method it is displayed in the browser, the other methods inside the class takes care about how to display in the browser,<br />So you need only to give the display() method body, no need to care about how it will be displayed in the broowser,<br />hope you understandbhabani pattanayakhttps://www.blogger.com/profile/09650249063755739808noreply@blogger.comtag:blogger.com,1999:blog-1235110526979374490.post-50693834136410748412010-08-27T07:09:26.499+05:302010-08-27T07:09:26.499+05:30ya exactly correct but..we can only declare using ...ya exactly correct but..we can only declare using abstract keyword in abstract class.. defining should be done in subclass like our class...<br /><br />raju.ponnarasu@gmail.comkillerhttps://www.blogger.com/profile/02350665452679021463noreply@blogger.com